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.
- Loading branch information
Showing
13 changed files
with
324 additions
and
37 deletions.
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,41 @@ | ||
--- | ||
name: Bug in DiceDB command | ||
about: Use this template to report bug in any command behaviour vs Redis | ||
title: 'Inconsistent `{CMD}`: <Describe the error in one concise line>' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
## Steps to reproduce | ||
|
||
{steps_to_reproduce} | ||
|
||
## Expected output | ||
|
||
The expected output when the above set of commands (maybe when run on Redis) | ||
|
||
``` | ||
{expected_output} | ||
``` | ||
|
||
## Observed output | ||
|
||
The observed output when the above set of commands when run on DiceDB | ||
|
||
``` | ||
{observed_output} | ||
``` | ||
|
||
## Expectations for resolution | ||
|
||
This issue will be considered resolved when the following things are done | ||
|
||
1. changes in the [`dice`](https://github.com/dicedb/dice) code to meet the expected behavior | ||
2. addition of relevant test case to ensure we catch the regression | ||
|
||
You can find the tests under the `tests` directory of the [`dice`](https://github.com/dicedb/dice) repository and the steps to run are in the [README file](https://github.com/dicedb/dice). Refer to the following links to set up DiceDB and Redis 7.2.5 locally | ||
|
||
- [setup DiceDB locally](https://github.com/dicedb/dice) | ||
- [setup Redis 7.2.5 locally](https://gist.github.com/arpitbbhayani/94aedf279349303ed7394197976b6843) | ||
- [setup DiceDB CLI](https://github.com/dicedb/dice) |
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
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,70 @@ | ||
package commands | ||
|
||
import ( | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestType(t *testing.T) { | ||
conn := getLocalConnection() | ||
defer conn.Close() | ||
|
||
testCases := []struct { | ||
name string | ||
commands []string | ||
expected []interface{} | ||
}{ | ||
{ | ||
name: "TYPE with invalid number of arguments", | ||
commands: []string{"TYPE"}, | ||
expected: []interface{}{"ERR wrong number of arguments for 'type' command"}, | ||
}, | ||
{ | ||
name: "TYPE for non-existent key", | ||
commands: []string{"TYPE k1"}, | ||
expected: []interface{}{"none"}, | ||
}, | ||
{ | ||
name: "TYPE for key with String value", | ||
commands: []string{"SET k1 v1", "TYPE k1"}, | ||
expected: []interface{}{"OK", "string"}, | ||
}, | ||
{ | ||
name: "TYPE for key with List value", | ||
commands: []string{"LPUSH k1 v1", "TYPE k1"}, | ||
expected: []interface{}{"OK", "list"}, | ||
}, | ||
{ | ||
name: "TYPE for key with Set value", | ||
commands: []string{"SADD k1 v1", "TYPE k1"}, | ||
expected: []interface{}{int64(1), "set"}, | ||
}, | ||
{ | ||
name: "TYPE for key with Hash value", | ||
commands: []string{"HSET k1 field1 v1", "TYPE k1"}, | ||
expected: []interface{}{int64(1), "hash"}, | ||
}, | ||
{ | ||
name: "TYPE for key with value created from SETBIT command", | ||
commands: []string{"SETBIT k1 1 1", "TYPE k1"}, | ||
expected: []interface{}{int64(0), "string"}, | ||
}, | ||
{ | ||
name: "TYPE for key with value created from SETOP command", | ||
commands: []string{"SET key1 \"foobar\"", "SET key2 \"abcdef\"", "BITOP AND dest key1 key2", "TYPE dest"}, | ||
expected: []interface{}{"OK", "OK", int64(6), "string"}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
FireCommand(conn, "DEL k1") | ||
|
||
for i, cmd := range tc.commands { | ||
result := FireCommand(conn, cmd) | ||
assert.Equal(t, tc.expected[i], result, "Value mismatch for cmd %s", cmd) | ||
} | ||
}) | ||
} | ||
} |
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
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
Oops, something went wrong.