Skip to content

Commit 60f5375

Browse files
committed
validate client name before kill it
1 parent 4f808f2 commit 60f5375

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

commands_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,21 @@ var _ = Describe("Commands", func() {
203203
opt := redisOptions()
204204
opt.ClientName = "killmyid"
205205
db := redis.NewClient(opt)
206+
Expect(db.Ping(ctx).Err()).NotTo(HaveOccurred())
206207

207208
defer func() {
208209
Expect(db.Close()).NotTo(HaveOccurred())
209210
}()
211+
val, err := client.ClientList(ctx).Result()
212+
Expect(err).NotTo(HaveOccurred())
213+
Expect(val).Should(ContainSubstring("name=killmyid"))
210214

211215
myid := db.ClientID(ctx).Val()
212216
killed := client.ClientKillByFilter(ctx, "ID", strconv.FormatInt(myid, 10))
213217
Expect(killed.Err()).NotTo(HaveOccurred())
214218
Expect(killed.Val()).To(BeNumerically("==", 1))
215219

216-
val, err := client.ClientList(ctx).Result()
220+
val, err = client.ClientList(ctx).Result()
217221
Expect(err).NotTo(HaveOccurred())
218222
Expect(val).ShouldNot(ContainSubstring("name=killmyid"))
219223
})

0 commit comments

Comments
 (0)