DATAREDIS-1111 - Add missing list and zset coroutine extensions.

Original Pull Request: #514
This commit is contained in:
wonwoo
2020-03-01 13:44:31 +09:00
committed by Christoph Strobl
parent df720bde8f
commit 62042a5d6d
4 changed files with 135 additions and 0 deletions

View File

@@ -334,6 +334,36 @@ class ReactiveListOperationsExtensionsUnitTests {
}
}
@Test
fun rightPopAndLeftPush() {
val operations = mockk<ReactiveListOperations<String, String>>()
every { operations.rightPopAndLeftPush(any(), any()) } returns Mono.just("foo")
runBlocking {
assertThat(operations.rightPopAndLeftPushAndAwait("foo", "bar")).isEqualTo("foo")
}
verify {
operations.rightPopAndLeftPush("foo", "bar")
}
}
@Test
fun blockingRightPopAndLeftPush() {
val operations = mockk<ReactiveListOperations<String, String>>()
every { operations.rightPopAndLeftPush(any(), any(), Duration.ofDays(1)) } returns Mono.just("foo")
runBlocking {
assertThat(operations.rightPopAndLeftPushAndAwait("foo", "bar", Duration.ofDays(1))).isEqualTo("foo")
}
verify {
operations.rightPopAndLeftPush("foo", "bar", Duration.ofDays(1))
}
}
@Test // DATAREDIS-937
fun delete() {

View File

@@ -304,6 +304,21 @@ class ReactiveZSetOperationsExtensionsUnitTests {
}
}
@Test
fun size() {
val operations = mockk<ReactiveZSetOperations<String, String>>()
every { operations.size(any()) } returns Mono.just(1)
runBlocking {
assertThat(operations.sizeAndAwait("foo")).isEqualTo(1)
}
verify {
operations.size("foo")
}
}
@Test // DATAREDIS-937
fun score() {
@@ -483,4 +498,49 @@ class ReactiveZSetOperationsExtensionsUnitTests {
operations.intersectAndStore("foo", listOf("bar"), "baz", Aggregate.MAX, Weights.fromSetCount(1))
}
}
@Test
fun rangeByLex() {
val operations = mockk<ReactiveZSetOperations<String, String>>()
every { operations.rangeByLex(any(), any()) } returns Flux.just("bar")
runBlocking {
assertThat(operations.rangeByLexAndAwait("foo", Range.just("bar")).toList()).contains("bar")
}
verify {
operations.rangeByLex("foo", Range.just("bar"))
}
}
@Test
fun reverseRangeByLexAndAwait() {
val operations = mockk<ReactiveZSetOperations<String, String>>()
every { operations.reverseRangeByLex(any(), any()) } returns Flux.just("bar")
runBlocking {
assertThat(operations.reverseRangeByLexAndAwait("foo", Range.just("bar")).toList()).contains("bar")
}
verify {
operations.reverseRangeByLex("foo", Range.just("bar"))
}
}
@Test
fun delete() {
val operations = mockk<ReactiveZSetOperations<String, String>>()
every { operations.delete(any()) } returns Mono.just(true)
runBlocking {
assertThat(operations.deleteAndAwait("foo")).isTrue()
}
verify {
operations.delete("foo")
}
}
}