From 11bf22b234d777246d9425b9402c9ab2811f5d4c Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Thu, 3 Sep 2020 16:47:40 +0800 Subject: [PATCH] Fix dns tests by setting v2ray.location.asset --- infra/conf/dns_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/infra/conf/dns_test.go b/infra/conf/dns_test.go index 25111c51..ca5a037f 100644 --- a/infra/conf/dns_test.go +++ b/infra/conf/dns_test.go @@ -20,11 +20,12 @@ func init() { wd, err := os.Getwd() common.Must(err) - if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat"))) + if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { + common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat"))) } - geositeFilePath := platform.GetAssetLocation("geosite.dat") + geositeFilePath := filepath.Join(wd, "geosite.dat") + os.Setenv("v2ray.location.asset", wd) geositeFile, err := os.OpenFile(geositeFilePath, os.O_CREATE|os.O_WRONLY, 0600) common.Must(err) defer geositeFile.Close() @@ -48,6 +49,7 @@ func TestDnsConfigParsing(t *testing.T) { geositePath := platform.GetAssetLocation("geosite.dat") defer func() { os.Remove(geositePath) + os.Unsetenv("v2ray.location.asset") }() parserCreator := func() func(string) (proto.Message, error) {