forked from DiceDB/dice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DiceDB#654: feat: Implement HSETNX command (DiceDB#715)
- Loading branch information
1 parent
4b30833
commit 1398403
Showing
4 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package async | ||
|
||
import ( | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestHSETNX(t *testing.T) { | ||
conn := getLocalConnection() | ||
defer conn.Close() | ||
|
||
testCases := []TestCase{ | ||
{ | ||
commands: []string{"HSETNX key_nx_t1 field value", "HSET key_nx_t1 field value_new"}, | ||
expected: []interface{}{ONE, ZERO}, | ||
}, | ||
{ | ||
commands: []string{"HSETNX key_nx_t2 field1 value1"}, | ||
expected: []interface{}{ONE}, | ||
}, | ||
{ | ||
commands: []string{"HSETNX key_nx_t3 field value", "HSETNX key_nx_t3 field new_value", "HSETNX key_nx_t3"}, | ||
expected: []interface{}{ONE, ZERO, "ERR wrong number of arguments for 'hsetnx' command"}, | ||
}, | ||
{ | ||
commands: []string{"SET key_nx_t4 v", "HSETNX key_nx_t4 f v"}, | ||
expected: []interface{}{"OK", "WRONGTYPE Operation against a key holding the wrong kind of value"}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
for i, cmd := range tc.commands { | ||
result := FireCommand(conn, cmd) | ||
assert.DeepEqual(t, tc.expected[i], result) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters