Skip to content

Commit

Permalink
Test: Redis supports UNWATCH within MULTI
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Nov 16, 2019
1 parent 1a237c6 commit 4a1d06b
Showing 1 changed file with 16 additions and 4 deletions.
Expand Up @@ -350,7 +350,6 @@ public void testCloseable() throws IOException {
}
}


@Test
public void testTransactionWithGeneralCommand(){
Transaction t = jedis.multi();
Expand All @@ -369,17 +368,14 @@ public void testTransactionWithGeneralCommand(){
Response<Object> 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();
Expand All @@ -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<Object> res = t.exec();
assertEquals(exp, res);
}

}

0 comments on commit 4a1d06b

Please sign in to comment.