Skip to content

Commit

Permalink
Merge pull request #161 from felixonmars/fix-test
Browse files Browse the repository at this point in the history
Fix dns tests by setting v2ray.location.asset
  • Loading branch information
vcptr committed Sep 3, 2020
2 parents 39e9916 + 11bf22b commit d2226cb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions infra/conf/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) {
Expand Down

0 comments on commit d2226cb

Please sign in to comment.