Fix dns tests by setting v2ray.location.asset

pull/2725/head
Felix Yan 4 years ago
parent 7001483b62
commit 11bf22b234
No known key found for this signature in database
GPG Key ID: 786C63F330D7CB92

@ -20,11 +20,12 @@ func init() {
wd, err := os.Getwd() wd, err := os.Getwd()
common.Must(err) common.Must(err)
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && os.IsNotExist(err) { if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) {
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat"))) 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) geositeFile, err := os.OpenFile(geositeFilePath, os.O_CREATE|os.O_WRONLY, 0600)
common.Must(err) common.Must(err)
defer geositeFile.Close() defer geositeFile.Close()
@ -48,6 +49,7 @@ func TestDnsConfigParsing(t *testing.T) {
geositePath := platform.GetAssetLocation("geosite.dat") geositePath := platform.GetAssetLocation("geosite.dat")
defer func() { defer func() {
os.Remove(geositePath) os.Remove(geositePath)
os.Unsetenv("v2ray.location.asset")
}() }()
parserCreator := func() func(string) (proto.Message, error) { parserCreator := func() func(string) (proto.Message, error) {

Loading…
Cancel
Save