mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-05 23:15:47 +08:00
新版IP库管理阶段性提交(未完成)
This commit is contained in:
@@ -8,11 +8,29 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRegionCountryDAO_FindCountryIdWithName(t *testing.T) {
|
||||
dbs.NotifyReady()
|
||||
|
||||
for _, name := range []string{
|
||||
"中国",
|
||||
"中华人民共和国",
|
||||
"美国",
|
||||
"美利坚合众国",
|
||||
"美利坚",
|
||||
} {
|
||||
countryId, err := SharedRegionCountryDAO.FindCountryIdWithName(nil, name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(name, ":", countryId)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegionCountryDAO_FindCountryIdWithCountryNameCacheable(t *testing.T) {
|
||||
dbs.NotifyReady()
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
now := time.Now()
|
||||
var now = time.Now()
|
||||
countryId, err := SharedRegionCountryDAO.FindCountryIdWithNameCacheable(nil, "中国")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -20,3 +38,24 @@ func TestRegionCountryDAO_FindCountryIdWithCountryNameCacheable(t *testing.T) {
|
||||
t.Log("countryId", countryId, time.Since(now).Seconds()*1000, "ms")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegionCountryDAO_FindSimilarCountries(t *testing.T) {
|
||||
dbs.NotifyReady()
|
||||
|
||||
var tx *dbs.Tx
|
||||
countries, err := SharedRegionCountryDAO.FindAllCountries(tx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, countryName := range []string{"中国", "布基纳法索", "哥伦比亚", "德意志共和国", "美利坚", "刚果金"} {
|
||||
t.Log("====" + countryName + "====")
|
||||
var countries = SharedRegionCountryDAO.FindSimilarCountries(countries, countryName, 5)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, country := range countries {
|
||||
t.Log(country.Name, country.AllCodes())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user