Skip to content

Commit

Permalink
Fix missing return value receiver when using slices.Compact (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk authored Sep 20, 2023
1 parent dda1407 commit 49c6248
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/gocase/unit/scan/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestScanEmptyKey(t *testing.T) {
keys, _, err := rdb.SScan(ctx, "sadd_key", 0, "*", 10000).Result()
require.NoError(t, err)
slices.Sort(keys)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Equal(t, []string{"", "fab", "fiz", "foobar"}, keys)
}

Expand Down Expand Up @@ -77,23 +77,23 @@ func ScanTest(t *testing.T, rdb *redis.Client, ctx context.Context) {
require.NoError(t, rdb.FlushDB(ctx).Err())
util.Populate(t, rdb, "", 1000, 10)
keys := scanAll(t, rdb)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Len(t, keys, 1000)
})

t.Run("SCAN COUNT", func(t *testing.T) {
require.NoError(t, rdb.FlushDB(ctx).Err())
util.Populate(t, rdb, "", 1000, 10)
keys := scanAll(t, rdb, "count", 5)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Len(t, keys, 1000)
})

t.Run("SCAN MATCH", func(t *testing.T) {
require.NoError(t, rdb.FlushDB(ctx).Err())
util.Populate(t, rdb, "key:", 1000, 10)
keys := scanAll(t, rdb, "match", "key:*")
slices.Compact(keys)
keys = slices.Compact(keys)
require.Len(t, keys, 1000)
})

Expand Down Expand Up @@ -127,7 +127,7 @@ func ScanTest(t *testing.T, rdb *redis.Client, ctx context.Context) {
}
originKeys = append(originKeys, key)
}
slices.Compact(originKeys)
originKeys = slices.Compact(originKeys)
require.Len(t, originKeys, 100)
})

Expand Down Expand Up @@ -173,7 +173,7 @@ func ScanTest(t *testing.T, rdb *redis.Client, ctx context.Context) {
keys, _, err := rdb.SScan(ctx, "mykey", 0, "foo*", 10000).Result()
require.NoError(t, err)
slices.Sort(keys)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Equal(t, []string{"foo", "foobar"}, keys)
})

Expand All @@ -183,7 +183,7 @@ func ScanTest(t *testing.T, rdb *redis.Client, ctx context.Context) {
keys, _, err := rdb.HScan(ctx, "mykey", 0, "foo*", 10000).Result()
require.NoError(t, err)
slices.Sort(keys)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Equal(t, []string{"1", "10", "foo", "foobar"}, keys)
})

Expand All @@ -199,7 +199,7 @@ func ScanTest(t *testing.T, rdb *redis.Client, ctx context.Context) {
keys, _, err := rdb.ZScan(ctx, "mykey", 0, "foo*", 10000).Result()
require.NoError(t, err)
slices.Sort(keys)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Equal(t, []string{"1", "10", "foo", "foobar"}, keys)
})

Expand All @@ -219,7 +219,7 @@ func ScanTest(t *testing.T, rdb *redis.Client, ctx context.Context) {
require.NoError(t, rdb.SAdd(ctx, "set", elements...).Err())
keys, _, err := rdb.SScan(ctx, "set", 0, "", 10000).Result()
require.NoError(t, err)
slices.Compact(keys)
keys = slices.Compact(keys)
require.Len(t, keys, 100)
})
}
Expand Down

0 comments on commit 49c6248

Please sign in to comment.