Skip to content

Commit 96776a9

Browse files
committed
Fix failing test
1 parent e9fa8f5 commit 96776a9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/test/java/io/lettuce/core/search/RediSearchAggregateIntegrationTests.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,8 +1349,16 @@ NumericFieldArgs.<String> builder().name("price").build(),
13491349
assertThat(nextResult.getReplies()).hasSize(1); // Should have 1 SearchReply
13501350
SearchReply<String, String> nextSearchReply = nextResult.getReplies().get(0);
13511351
assertThat(nextSearchReply.getResults()).hasSize(1); // Should return second group
1352-
assertThat(nextResult.getCursor()).isPresent();
1353-
assertThat(nextResult.getCursor().get().getCursorId()).isEqualTo(0L); // Should indicate end of results
1352+
// RediSearch may either omit the cursor on the final page, or return a non-zero cursor
1353+
// that requires one more empty READ to return 0. Be tolerant across versions.
1354+
long effective = nextResult.getCursor().map(AggregationReply.Cursor::getCursorId).orElse(0L);
1355+
if (effective != 0L) {
1356+
AggregationReply<String, String> finalPage = redis.ftCursorread("cursor-complex-test-idx", nextResult.getCursor().get());
1357+
assertThat(finalPage).isNotNull();
1358+
assertThat(finalPage.getReplies()).hasSize(1);
1359+
assertThat(finalPage.getReplies().get(0).getResults()).isEmpty();
1360+
assertThat(finalPage.getCursor().map(AggregationReply.Cursor::getCursorId).orElse(0L)).isEqualTo(0L);
1361+
}
13541362

13551363
// Verify second group has expected fields
13561364
SearchReply.SearchResult<String, String> secondGroup = nextSearchReply.getResults().get(0);

0 commit comments

Comments
 (0)