From: Debian Go Packaging Team Date: Fri, 11 Aug 2023 18:59:45 +0800 Subject: Remove geoip dependency for tests Closes: #1034367 --- app/router/condition_geoip_test.go | 15 ++++++++++----- app/router/condition_test.go | 11 ++++++----- infra/conf/dns_test.go | 13 +++++++------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/router/condition_geoip_test.go b/app/router/condition_geoip_test.go index 9c73393..1a37b65 100644 --- a/app/router/condition_geoip_test.go +++ b/app/router/condition_geoip_test.go @@ -1,20 +1,20 @@ package router_test import ( - "os" - "path/filepath" +// "os" +// "path/filepath" "testing" "github.com/golang/protobuf/proto" "v2ray.com/core/app/router" "v2ray.com/core/common" "v2ray.com/core/common/net" - "v2ray.com/core/common/platform" +// "v2ray.com/core/common/platform" "v2ray.com/core/common/platform/filesystem" ) func init() { - wd, err := os.Getwd() +/* wd, err := os.Getwd() common.Must(err) if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { @@ -22,10 +22,11 @@ func init() { } 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"))) - } + }*/ } func TestGeoIPMatcherContainer(t *testing.T) { + t.Skip() container := &router.GeoIPMatcherContainer{} m1, err := container.Add(&router.GeoIP{ @@ -124,6 +125,7 @@ func TestGeoIPMatcher(t *testing.T) { } func TestGeoIPMatcher4CN(t *testing.T) { + t.Skip() ips, err := loadGeoIP("CN") common.Must(err) @@ -136,6 +138,7 @@ func TestGeoIPMatcher4CN(t *testing.T) { } func TestGeoIPMatcher6US(t *testing.T) { + t.Skip() ips, err := loadGeoIP("US") common.Must(err) @@ -167,6 +170,7 @@ func loadGeoIP(country string) ([]*router.CIDR, error) { } func BenchmarkGeoIPMatcher4CN(b *testing.B) { + b.Skip() ips, err := loadGeoIP("CN") common.Must(err) @@ -181,6 +185,7 @@ func BenchmarkGeoIPMatcher4CN(b *testing.B) { } func BenchmarkGeoIPMatcher6US(b *testing.B) { + b.Skip() ips, err := loadGeoIP("US") common.Must(err) diff --git a/app/router/condition_test.go b/app/router/condition_test.go index 05d7346..0f4aad2 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -1,8 +1,8 @@ package router_test import ( - "os" - "path/filepath" +// "os" +// "path/filepath" "strconv" "testing" @@ -12,7 +12,7 @@ import ( "v2ray.com/core/common" "v2ray.com/core/common/errors" "v2ray.com/core/common/net" - "v2ray.com/core/common/platform" +// "v2ray.com/core/common/platform" "v2ray.com/core/common/platform/filesystem" "v2ray.com/core/common/protocol" "v2ray.com/core/common/protocol/http" @@ -22,7 +22,7 @@ import ( ) func init() { - wd, err := os.Getwd() +/* wd, err := os.Getwd() common.Must(err) if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { @@ -30,7 +30,7 @@ func init() { } 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"))) - } + }*/ } func withBackground() routing.Context { @@ -353,6 +353,7 @@ func loadGeoSite(country string) ([]*Domain, error) { } func TestChinaSites(t *testing.T) { + t.Skip() domains, err := loadGeoSite("CN") common.Must(err) diff --git a/infra/conf/dns_test.go b/infra/conf/dns_test.go index 27ff084..514c4c6 100644 --- a/infra/conf/dns_test.go +++ b/infra/conf/dns_test.go @@ -3,21 +3,21 @@ package conf_test import ( "encoding/json" "os" - "path/filepath" +// "path/filepath" "testing" "github.com/golang/protobuf/proto" "v2ray.com/core/app/dns" - "v2ray.com/core/app/router" - "v2ray.com/core/common" +// "v2ray.com/core/app/router" +// "v2ray.com/core/common" "v2ray.com/core/common/net" "v2ray.com/core/common/platform" - "v2ray.com/core/common/platform/filesystem" +// "v2ray.com/core/common/platform/filesystem" . "v2ray.com/core/infra/conf" ) func init() { - wd, err := os.Getwd() +/* wd, err := os.Getwd() common.Must(err) if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { @@ -43,10 +43,11 @@ func init() { listBytes, err := proto.Marshal(list) common.Must(err) - common.Must2(geositeFile.Write(listBytes)) + common.Must2(geositeFile.Write(listBytes))*/ } func TestDNSConfigParsing(t *testing.T) { + t.Skip() geositePath := platform.GetAssetLocation("geosite.dat") defer func() { os.Remove(geositePath)