[ 
https://issues.apache.org/jira/browse/GEODE-8858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17269656#comment-17269656
 ] 

ASF GitHub Bot commented on GEODE-8858:
---------------------------------------

sabbey37 commented on a change in pull request #5940:
URL: https://github.com/apache/geode/pull/5940#discussion_r562207431



##########
File path: 
geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/hash/AbstractHashesIntegrationTest.java
##########
@@ -365,6 +365,40 @@ public void testHSetNXExecutor() {
 
   }
 
+  @Test
+  public void hsetNX_shouldThrowErrorIfKeyIsWrongType() {
+    String string_key = "String_Key";
+    String set_key = "Set_Key";
+    String field = "field";
+    String value = "value";
+
+    jedis.set(string_key, value);
+    jedis.sadd(set_key, field);
+
+    assertThatThrownBy(
+        () -> jedis.hsetnx(string_key, field, "something else"))
+            .isInstanceOf(JedisDataException.class)
+            .hasMessageContaining("WRONGTYPE");
+    assertThatThrownBy(
+        () -> jedis.hsetnx(set_key, field, "something 
else")).isInstanceOf(JedisDataException.class)
+            .hasMessageContaining("WRONGTYPE");
+
+    jedis.del(string_key);
+    jedis.del(set_key);
+  }
+
+  @Test
+  public void hsetnx_shouldThrowError_givenWrongNumberOfArguments() {
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSETNX))
+        .hasMessageContaining("wrong number of arguments");
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSETNX, "1"))
+        .hasMessageContaining("wrong number of arguments");
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSETNX, "1", 
"2"))
+        .hasMessageContaining("wrong number of arguments");
+    assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.HSETNX, "1", 
"2", "3", "4"))
+        .hasMessageContaining("wrong number of arguments");
+  }

Review comment:
       This is great!  Thanks for adding these.  I know for most of the other 
commands (del, getset, exists, etc.) we check the error message more closely, 
like:
   
   ```
   .hasMessageContaining("ERR wrong number of arguments for 'get' command");
   ```
   I'm not sure if it's necessary, but maybe we could do the same here to be 
consistent?  I realize there are a few areas where we're still just checking 
`wrong number of arguments`.  We could eventually change those in a different 
PR.




----------------------------------------------------------------
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:
us...@infra.apache.org


> Unit/Integration tests for HSETNX command
> -----------------------------------------
>
>                 Key: GEODE-8858
>                 URL: https://issues.apache.org/jira/browse/GEODE-8858
>             Project: Geode
>          Issue Type: Test
>          Components: redis
>            Reporter: Raymond Ingles
>            Priority: Major
>              Labels: pull-request-available
>
> Flesh out unit/integration tests for Redis HSETNX command.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to