Skip to content

Commit ab53758

Browse files
christophstroblmp911de
authored andcommitted
DATAREDIS-790 - Polishing.
Add unit tests. Original Pull Request: #291. Original ticket: DATAREDIS-714.
1 parent 99b18c4 commit ab53758

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionUnitTestSuite.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,25 @@ public void hScanShouldCloseTheConnectionWhenCursorIsClosed() throws IOException
258258
verify(jedisSpy, times(1)).quit();
259259
}
260260

261+
@Test // DATAREDIS-714, DATAREDIS-790
262+
public void doesNotSelectDbWhenCurrentDbMatchesDesiredOne() {
263+
264+
Jedis jedisSpy = spy(new MockedClientJedis("http://localhost:1234", getNativeRedisConnectionMock()));
265+
new JedisConnection(jedisSpy);
266+
267+
verify(jedisSpy, never()).select(anyInt());
268+
}
269+
270+
@Test // DATAREDIS-714, DATAREDIS-790
271+
public void doesNotSelectDbWhenCurrentDbDoesNotMatchDesiredOne() {
272+
273+
Jedis jedisSpy = spy(new MockedClientJedis("http://localhost:1234", getNativeRedisConnectionMock()));
274+
when(jedisSpy.getDB()).thenReturn(3L);
275+
276+
new JedisConnection(jedisSpy);
277+
278+
verify(jedisSpy).select(eq(0));
279+
}
261280
}
262281

263282
public static class JedisConnectionPipelineUnitTests extends JedisConnectionUnitTests {

0 commit comments

Comments
 (0)