From 4a1d06b869948527a560e6a3b0eb4ca8c2a293d8 Mon Sep 17 00:00:00 2001 From: sazzad16 Date: Wed, 16 Oct 2019 15:53:01 +0600 Subject: [PATCH] Test: Redis supports UNWATCH within MULTI --- .../commands/TransactionCommandsTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/test/java/redis/clients/jedis/tests/commands/TransactionCommandsTest.java b/src/test/java/redis/clients/jedis/tests/commands/TransactionCommandsTest.java index b6ce9592ba..f65351255c 100644 --- a/src/test/java/redis/clients/jedis/tests/commands/TransactionCommandsTest.java +++ b/src/test/java/redis/clients/jedis/tests/commands/TransactionCommandsTest.java @@ -350,7 +350,6 @@ public void testCloseable() throws IOException { } } - @Test public void testTransactionWithGeneralCommand(){ Transaction t = jedis.multi(); @@ -369,17 +368,14 @@ public void testTransactionWithGeneralCommand(){ Response x = t.sendCommand(GET, "x"); t.exec(); - assertEquals("foo", string.get()); assertEquals("foo", list.get()); assertEquals("bar", hash.get()); assertEquals("foo", zset.get().iterator().next()); assertEquals("foo", set.get()); assertEquals("2", SafeEncoder.encode((byte[]) x.get())); - } - @Test public void transactionResponseWithErrorWithGeneralCommand() { Transaction t = jedis.multi(); @@ -401,4 +397,20 @@ public void transactionResponseWithErrorWithGeneralCommand() { assertEquals("1", SafeEncoder.encode((byte[]) x.get())); } + @Test + public void unwatchWithinMulti() { + final String key = "foo"; + final String val = "bar"; + jedis.set(key, val); + jedis.watch(key); + + List exp = new ArrayList(); + Transaction t = jedis.multi(); + t.get(key); exp.add(val); + t.unwatch(); exp.add("OK"); + t.get(key); exp.add(val); + List res = t.exec(); + assertEquals(exp, res); + } + } \ No newline at end of file