1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-25 15:09:09 -04:00

Refine geodata related tests (#967)

This commit is contained in:
Loyalsoldier
2021-05-04 16:30:23 +08:00
committed by GitHub
parent de71e63893
commit 7805ca2ac1
5 changed files with 54 additions and 75 deletions

View File

@@ -20,17 +20,15 @@ func init() {
common.Must(err)
tempPath := filepath.Join(wd, "..", "..", "testing", "temp")
geoipPath := filepath.Join(tempPath, "geoip.dat")
os.Setenv("v2ray.location.asset", tempPath)
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geoipBytes, err := common.FetchHTTPContent(geoipURL)
common.Must(err)
common.Must(filesystem.WriteFile(geoipPath, geoipBytes))
}
geoipPath := platform.GetAssetLocation("geoip.dat")
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geoipBytes, err := common.FetchHTTPContent(geoipURL)
common.Must(err)
common.Must(filesystem.WriteFile(geoipPath, geoipBytes))
}
}