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
33 changed files
with
2,672 additions
and
341 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.21 as builder | ||
FROM golang:1.23 as builder | ||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
|
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
services: | ||
dicedb: | ||
image: dicedb/dicedb:0.0.2 | ||
platform: linux/amd64 | ||
ports: | ||
- "7379:7379" | ||
|
||
|
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
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,64 @@ | ||
package commands | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/dicedb/dice/testutils" | ||
testifyAssert "github.com/stretchr/testify/assert" | ||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestJSONARRPOP(t *testing.T) { | ||
conn := getLocalConnection() | ||
defer conn.Close() | ||
FireCommand(conn, "DEL key") | ||
|
||
arrayAtRoot := `[0,1,2,3]` | ||
nestedArray := `{"a":2,"b":[0,1,2,3]}` | ||
|
||
testCases := []struct { | ||
name string | ||
commands []string | ||
expected []interface{} | ||
assert_type []string | ||
jsonResp []bool | ||
nestedArray bool | ||
path string | ||
}{ | ||
{ | ||
name: "update array at root path", | ||
commands: []string{"json.set key $ " + arrayAtRoot, "json.arrpop key $ 2", "json.get key"}, | ||
expected: []interface{}{"OK", int64(2), "[0,1,3]"}, | ||
assert_type: []string{"equal", "equal", "deep_equal"}, | ||
}, | ||
{ | ||
name: "update nested array", | ||
commands: []string{"json.set key $ " + nestedArray, "json.arrpop key $.b 2", "json.get key"}, | ||
expected: []interface{}{"OK", []interface{}{int64(2)}, `{"a":2,"b":[0,1,3]}`}, | ||
assert_type: []string{"equal", "deep_equal", "na"}, | ||
}, | ||
} | ||
|
||
for _, tcase := range testCases { | ||
t.Run(tcase.name, func(t *testing.T) { | ||
for i := 0; i < len(tcase.commands); i++ { | ||
cmd := tcase.commands[i] | ||
out := tcase.expected[i] | ||
result := FireCommand(conn, cmd) | ||
|
||
jsonResult, isString := result.(string) | ||
|
||
if isString && testutils.IsJSONResponse(jsonResult) { | ||
testifyAssert.JSONEq(t, out.(string), jsonResult) | ||
continue | ||
} | ||
|
||
if tcase.assert_type[i] == "equal" { | ||
assert.Equal(t, out, result) | ||
} else if tcase.assert_type[i] == "deep_equal" { | ||
assert.Assert(t, arraysArePermutations(out.([]interface{}), result.([]interface{}))) | ||
} | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.