Skip to content

Commit cb60e72

Browse files
DATAREDIS-714 - Polishing.
Add unit tests. Original Pull Request: #291
1 parent 2815da6 commit cb60e72

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
@@ -257,6 +257,25 @@ public void hScanShouldCloseTheConnectionWhenCursorIsClosed() throws IOException
257257
verify(jedisSpy, times(1)).quit();
258258
}
259259

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

262281
public static class JedisConnectionPipelineUnitTests extends JedisConnectionUnitTests {

0 commit comments

Comments
 (0)