Skip to content

Commit

Permalink
[streams] 0 id in xadd
Browse files Browse the repository at this point in the history
  • Loading branch information
Iван committed Dec 8, 2023
1 parent a3d8103 commit a2d4153
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import org.junit.jupiter.api.extension.ExtendWith;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.StreamEntryID;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.params.XAddParams;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

@ExtendWith(ComparisonBase.class)
public class XAddTests {
Expand Down Expand Up @@ -158,4 +156,13 @@ void whenNomkstream_ensureReturnsNull(Jedis jedis) {
Map.of("a", "b")
));
}

@TestTemplate
void whenZeroId_ensureThrowsException(Jedis jedis) {
assertThrows(
JedisDataException.class,
() -> jedis.xadd("s", XAddParams.xAddParams().id("0"), Map.of("a", "b")),
"ERR The ID specified in XADD is equal or smaller than the target stream top item"
);
}
}

0 comments on commit a2d4153

Please sign in to comment.