Skip to content

Commit

Permalink
Fix tests and add tests withArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ggivo committed Oct 30, 2024
1 parent 7a9ca22 commit d67c63f
Showing 1 changed file with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ void before() {
connection1 = client.connect(node1).sync();
connection2 = client.connect(node2).sync();

connection1.flushall();
connection2.flushall();

RedisInstance node1Instance = RoleParser.parse(this.connection1.role());
RedisInstance node2Instance = RoleParser.parse(this.connection2.role());

Expand All @@ -62,9 +59,11 @@ void before() {
String.format("Cannot run the test because I don't have a distinct master and replica but %s and %s",
node1Instance, node2Instance));
}
upstream.flushall();

masterReplica = MasterReplica.connect(client, StringCodec.UTF8, Arrays.asList(node1, node2));
masterReplica.setReadFrom(ReadFrom.REPLICA);

}

@AfterEach
Expand Down Expand Up @@ -99,6 +98,19 @@ void georadiusReadFromReplica() {
assertThat(georadius).hasSize(1).contains("Weinheim");
}

@Test
void georadiusWithArgsReadFromReplica() {

prepareGeo(upstream);

upstream.waitForReplication(1, 1000);

GeoArgs geoArgs = new GeoArgs().withHash().withCoordinates().withDistance().withCount(1).desc();

List<GeoWithin<String>> result = masterReplica.sync().georadius(key, 8.665351, 49.553302, 5, GeoArgs.Unit.km, geoArgs);
assertThat(result).hasSize(1);
}

@Test
void georadiusbymemberReadFromReplica() {

Expand All @@ -109,6 +121,17 @@ void georadiusbymemberReadFromReplica() {
assertThat(empty).hasSize(1).contains("Bahn");
}

@Test
void georadiusbymemberWithArgsReadFromReplica() {

prepareGeo(upstream);
upstream.waitForReplication(1, 100);

List<GeoWithin<String>> empty = masterReplica.sync().georadiusbymember(key, "Bahn", 1, GeoArgs.Unit.km,
new GeoArgs().withHash().withCoordinates().withDistance().desc());
assertThat(empty).isNotEmpty();
}

protected void prepareGeo(RedisCommands<String, String> redis) {
redis.geoadd(key, 8.6638775, 49.5282537, "Weinheim");
redis.geoadd(key, 8.3796281, 48.9978127, "EFS9", 8.665351, 49.553302, "Bahn");
Expand Down

0 comments on commit d67c63f

Please sign in to comment.