Skip to content

Commit

Permalink
Added better error info for set comparison failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jduo committed Jun 28, 2024
1 parent 3ed5904 commit c05af38
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -7180,14 +7180,21 @@ public void zscan(BaseClient client) {
resultKeys.add(resultArray[i]);
resultValues.add(resultArray[i + 1]);
}
assertTrue(resultKeys.containsAll(charMap.keySet()));
assertTrue(
resultKeys.containsAll(charMap.keySet()),
String.format("resultKeys: {%s} charMap.keySet(): {%s}", resultKeys, charMap.keySet()));

// The score comes back as an integer converted to a String when the fraction is zero.
final Set<String> expectedScoresAsStrings =
charMap.values().stream()
.map(v -> String.valueOf(v.intValue()))
.collect(Collectors.toSet());

assertTrue(
resultValues.containsAll(
charMap.values().stream()
.map(v -> String.valueOf(v.intValue()))
.collect(Collectors.toSet())));
resultValues.containsAll(expectedScoresAsStrings),
String.format(
"resultValues: {%s} expectedScoresAsStrings: {%s}",
resultValues, expectedScoresAsStrings));

result =
client.zscan(key1, initialCursor, ZScanOptions.builder().matchPattern("a").build()).get();
Expand Down Expand Up @@ -7221,11 +7228,16 @@ public void zscan(BaseClient client) {
} while (resultCursor != 0); // 0 is returned for the cursor of the last iteration.

assertTrue(secondResultAllKeys.containsAll(numberMap.keySet()));
final Set<String> numberMapValuesAsStrings =
numberMap.values().stream()
.map(d -> String.valueOf(d.intValue()))
.collect(Collectors.toSet());

assertTrue(
secondResultAllValues.containsAll(
numberMap.values().stream()
.map(d -> String.valueOf(d.intValue()))
.collect(Collectors.toSet())));
secondResultAllValues.containsAll(numberMapValuesAsStrings),
String.format(
"secondResultAllValues: {%s} numberMapValuesAsStrings: {%s}",
secondResultAllValues, numberMapValuesAsStrings));

// Test match pattern
result =
Expand Down

0 comments on commit c05af38

Please sign in to comment.