nonbinaryprogrammer commented on a change in pull request #6025:
URL: https://github.com/apache/geode/pull/6025#discussion_r574724909



##########
File path: 
geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/string/AbstractStringIntegrationTest.java
##########
@@ -128,6 +130,62 @@ public void testStrlen_withFloatData() {
     assertThat(jedis.strlen(key)).isEqualTo(value.length);
   }
 
+  @Test
+  public void testIncr_ErrorsWithWrongNumberOfArguments() {
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.INCR))
+        .hasMessageContaining("ERR wrong number of arguments for 'incr' 
command");
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.INCR, "1", 
"2"))
+        .hasMessageContaining("ERR wrong number of arguments for 'incr' 
command");
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.INCR, "1", 
"2", "3"))
+        .hasMessageContaining("ERR wrong number of arguments for 'incr' 
command");
+  }
+
+  @Test
+  public void testIncr_errorsGivenWrongType() {
+    String key1 = "hashKey";
+    String key2 = "key";
+
+    jedis.hset(key1, "field", "non-int value");
+    jedis.set(key2, "non-int value");
+
+    assertThatThrownBy(() -> jedis.incr(key1))
+        .isInstanceOf(JedisDataException.class)
+        .hasMessageContaining(RedisConstants.ERROR_WRONG_TYPE);
+    assertThatThrownBy(() -> jedis.incr(key2))
+        .isInstanceOf(JedisDataException.class)
+        .hasMessageContaining(RedisConstants.ERROR_NOT_INTEGER);
+  }
+
+  @Test
+  public void testIncr_incrementsPositiveAndNegativeIntegerValues() {
+    String key1 = "positiveKey";
+    String key2 = "negativeKey";
+
+    jedis.set(key1, "10");
+    jedis.set(key2, "-10");
+
+    jedis.incr(key1);
+    jedis.incr(key2);
+
+    assertThat(Long.parseLong(jedis.get(key1))).isEqualTo(11L);
+    assertThat(Long.parseLong(jedis.get(key2))).isEqualTo(-9L);
+  }
+
+  @Test
+  public void testConcurrentIncr_performsAllIncrs() {
+    Jedis jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+    String key = "key";
+    int expectedValue = NUM_ITERATIONS * 2;
+
+    jedis.set(key, "0");
+
+    new ConcurrentLoopingThreads(NUM_ITERATIONS,
+        (i) -> jedis.incr(key),
+        (i) -> jedis2.incr(key)).run();
+
+    assertThat(Integer.parseInt(jedis.get(key))).isEqualTo(expectedValue);
+  }
+

Review comment:
       Good ideas, I'll do that :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to