Skip to content

Commit

Permalink
Add tests for Stream pipelined commands (#3763)
Browse files Browse the repository at this point in the history
* Add tests for Stream pipelined commands

Also adapt some migration pipelined tests, to assert the exact content
of collections, not just subsets.

* Simplify one test case

---------

Co-authored-by: Gabriel Erzse <[email protected]>
  • Loading branch information
gerzse and gerzse authored Mar 11, 2024
1 parent 2394380 commit 7515d5a
Show file tree
Hide file tree
Showing 2 changed files with 1,334 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/test/java/redis/clients/jedis/MigratePipeliningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertArrayEquals;
Expand Down Expand Up @@ -72,7 +72,7 @@ public void noKey() {
p.migrate(host, port, db, timeout, new MigrateParams(), bfoo1, bfoo2, bfoo3);

assertThat(p.syncAndReturnAll(),
hasItems("NOKEY", "NOKEY", "NOKEY", "NOKEY"));
contains("NOKEY", "NOKEY", "NOKEY", "NOKEY"));
}

@Test
Expand All @@ -86,7 +86,7 @@ public void migrate() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertEquals("bar", dest.get("foo"));
}
Expand All @@ -102,7 +102,7 @@ public void migrateBinary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertArrayEquals(bbar, dest.get(bfoo));
}
Expand All @@ -118,7 +118,7 @@ public void migrateEmptyParams() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertEquals("bar", dest.get("foo"));
}
Expand All @@ -134,7 +134,7 @@ public void migrateEmptyParamsBinary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertArrayEquals(bbar, dest.get(bfoo));
}
Expand All @@ -150,7 +150,7 @@ public void migrateCopy() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", "bar"));
contains("OK", "OK", "bar"));

assertEquals("bar", dest.get("foo"));
}
Expand All @@ -166,7 +166,7 @@ public void migrateCopyBinary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", bbar));
contains("OK", "OK", bbar));

assertArrayEquals(bbar, dest.get(bfoo));
}
Expand All @@ -184,7 +184,7 @@ public void migrateReplace() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertEquals("bar1", dest.get("foo"));
}
Expand All @@ -202,7 +202,7 @@ public void migrateReplaceBinary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertArrayEquals(bbar1, dest.get(bfoo));
}
Expand All @@ -220,7 +220,7 @@ public void migrateCopyReplace() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", "bar1"));
contains("OK", "OK", "bar1"));

assertEquals("bar1", dest.get("foo"));
}
Expand All @@ -238,7 +238,7 @@ public void migrateCopyReplaceBinary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", bbar1));
contains("OK", "OK", bbar1));

assertArrayEquals(bbar1, dest.get(bfoo));
}
Expand All @@ -254,7 +254,7 @@ public void migrateAuth() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertEquals("bar", destAuth.get("foo"));
}
Expand All @@ -270,7 +270,7 @@ public void migrateAuthBinary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertArrayEquals(bbar, destAuth.get(bfoo));
}
Expand All @@ -287,7 +287,7 @@ public void migrateAuth2() {
p.get("foo");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertEquals("bar", jedis.get("foo"));
}
Expand All @@ -304,7 +304,7 @@ public void migrateAuth2Binary() {
p.get(bfoo);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK", null));
contains("OK", "OK", null));

assertArrayEquals(bbar, jedis.get(bfoo));
}
Expand All @@ -321,7 +321,7 @@ public void migrateMulti() {
p.migrate(host, port, db, timeout, new MigrateParams(), "foo1", "foo2", "foo3");

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK"));
contains("OK", "OK"));

assertEquals("bar1", dest.get("foo1"));
assertEquals("bar2", dest.get("foo2"));
Expand All @@ -340,7 +340,7 @@ public void migrateMultiBinary() {
p.migrate(host, port, db, timeout, new MigrateParams(), bfoo1, bfoo2, bfoo3);

assertThat(p.syncAndReturnAll(),
hasItems("OK", "OK"));
contains("OK", "OK"));

assertArrayEquals(bbar1, dest.get(bfoo1));
assertArrayEquals(bbar2, dest.get(bfoo2));
Expand All @@ -361,7 +361,7 @@ public void migrateConflict() {
p.migrate(host, port, db, timeout, new MigrateParams(), "foo1", "foo2", "foo3");

assertThat(p.syncAndReturnAll(),
hasItems(
contains(
equalTo("OK"),
both(instanceOf(JedisDataException.class)).and(hasToString(containsString("BUSYKEY")))
));
Expand All @@ -385,7 +385,7 @@ public void migrateConflictBinary() {
p.migrate(host, port, db, timeout, new MigrateParams(), bfoo1, bfoo2, bfoo3);

assertThat(p.syncAndReturnAll(),
hasItems(
contains(
equalTo("OK"),
both(instanceOf(JedisDataException.class)).and(hasToString(containsString("BUSYKEY")))
));
Expand Down
Loading

0 comments on commit 7515d5a

Please sign in to comment.