Skip to content

Commit 5a118a1

Browse files
committed
Updated tests for redis
1 parent 1aa9a24 commit 5a118a1

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

splitio/client/client_test.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/splitio/go-client/v6/splitio"
1818
"github.com/splitio/go-client/v6/splitio/conf"
1919
impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
20+
"github.com/stretchr/testify/assert"
2021

2122
commonsCfg "github.com/splitio/go-split-commons/v8/conf"
2223
"github.com/splitio/go-split-commons/v8/dtos"
@@ -3193,6 +3194,13 @@ func TestRuleBasedSegmentRedis(t *testing.T) {
31933194
}
31943195

31953196
prefixedClient, _ := redis.NewRedisClient(redisConfig, logging.NewLogger(&logging.LoggerOptions{}))
3197+
// Clean redis
3198+
defer func() {
3199+
keys, _ := prefixedClient.Keys("test-prefix-rulebased*")
3200+
for _, k := range keys {
3201+
prefixedClient.Del(k)
3202+
}
3203+
}()
31963204
raw, _ := json.Marshal(*splitRuleBased)
31973205
prefixedClient.Set("SPLITIO.split.rbsplit", raw, 0)
31983206
rbraw, _ := json.Marshal(*rbsegment1)
@@ -3208,23 +3216,13 @@ func TestRuleBasedSegmentRedis(t *testing.T) {
32083216

32093217
factory, _ := NewSplitFactory("test", cfg)
32103218
client := factory.Client()
3211-
client.BlockUntilReady(2)
32123219

32133220
// Calls treatments to generate one valid impression
3214-
time.Sleep(300 * time.Millisecond) // Let's wait until first call of recorders have finished
32153221
attributes := make(map[string]interface{})
32163222
attributes["version"] = "3.4.5"
32173223
evaluation := client.Treatment("user1", "rbsplit", attributes)
3218-
if evaluation != "on" {
3219-
t.Error("evaluation for rbsplit should be on")
3220-
}
3224+
assert.Equal(t, "on", evaluation, "evaluation for rbsplit should be on")
32213225
client.Destroy()
3222-
3223-
// Clean redis
3224-
keys, _ := prefixedClient.Keys("SPLITIO*")
3225-
for _, k := range keys {
3226-
prefixedClient.Del(k)
3227-
}
32283226
}
32293227

32303228
func TestPrerequisites(t *testing.T) {

0 commit comments

Comments
 (0)