新版IP库管理阶段性提交(未完成)

This commit is contained in:
刘祥超
2022-08-13 23:55:48 +08:00
parent 9ddf02a0e6
commit ba938e5361
42 changed files with 2628 additions and 172 deletions

View File

@@ -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())
}
}
}