Skip to content

Commit

Permalink
test(os/gcache): fix unit testing occasionally failed due to too shor…
Browse files Browse the repository at this point in the history
…t expration duration set (#3842)
  • Loading branch information
gqcn authored Oct 8, 2024
1 parent 2301de6 commit 7cbc9e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions database/gdb/gdb_model_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func (m *Model) Data(data ...interface{}) *Model {
model.data = s
model.extraArgs = data[1:]
} else {
m := make(map[string]interface{})
newData := make(map[string]interface{})
for i := 0; i < len(data); i += 2 {
m[gconv.String(data[i])] = data[i+1]
newData[gconv.String(data[i])] = data[i+1]
}
model.data = m
model.data = newData
}
} else if len(data) == 1 {
switch value := data[0].(type) {
Expand Down
4 changes: 2 additions & 2 deletions os/gcache/gcache_z_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ func TestCache_LRU(t *testing.T) {
func TestCache_LRU_expire(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
cache := gcache.New(2)
t.Assert(cache.Set(ctx, 1, nil, time.Millisecond), nil)
t.Assert(cache.Set(ctx, 1, nil, 50*time.Millisecond), nil)

n, _ := cache.Size(ctx)
t.Assert(n, 1)

time.Sleep(time.Millisecond * 10)
time.Sleep(time.Millisecond * 100)

n, _ = cache.Size(ctx)
t.Assert(n, 0)
Expand Down

0 comments on commit 7cbc9e8

Please sign in to comment.