improve ut case for package gcache/gpool (#2290)

* improve ut case for package gcache/gpool

* up
This commit is contained in:
John Guo 2022-11-12 10:49:48 +08:00 committed by GitHub
parent b84034b667
commit 7d1a508ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -179,6 +179,6 @@ func ExamplePool_Close() {
// wait for pool close
time.Sleep(time.Second * 1)
// Output:
// May Output:
// Close The Pool
}

View File

@ -172,6 +172,7 @@ func TestCache_LRU(t *testing.T) {
v, _ := cache.Get(ctx, 6)
t.Assert(v, 6)
time.Sleep(4 * time.Second)
g.Log().Debugf(ctx, `items after lru: %+v`, cache.MustData(ctx))
n, _ = cache.Size(ctx)
t.Assert(n, 2)
v, _ = cache.Get(ctx, 6)

View File

@ -17,13 +17,14 @@ func IsSubDomain(subDomain string, mainDomain string) bool {
if p := strings.IndexByte(mainDomain, ':'); p != -1 {
mainDomain = mainDomain[0:p]
}
subArray := strings.Split(subDomain, ".")
mainArray := strings.Split(mainDomain, ".")
subLength := len(subArray)
mainLength := len(mainArray)
var (
subArray = strings.Split(subDomain, ".")
mainArray = strings.Split(mainDomain, ".")
subLength = len(subArray)
mainLength = len(mainArray)
)
// Eg:
// goframe.org is not sub-dome of 's.goframe.org'
// "goframe.org" is not sub-domain of "s.goframe.org".
if mainLength > subLength {
for i := range mainArray[0 : mainLength-subLength] {
if mainArray[i] != "*" {