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#734: Http Integration tests for COMMAND and COMMAND/COUNT (Dic…
- Loading branch information
Showing
3 changed files
with
100 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package http | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/dicedb/dice/internal/eval" | ||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestCommandDefault(t *testing.T) { | ||
exec := NewHTTPCommandExecutor() | ||
commands := getCommandDefault(exec) | ||
t.Run("Command should not be empty", func(t *testing.T) { | ||
assert.Assert(t, len(commands) > 0, | ||
fmt.Sprintf("Unexpected number of CLI commands found. expected greater than 0, %d found", len(commands))) | ||
}) | ||
|
||
t.Run("Command count matches", func(t *testing.T) { | ||
assert.Assert(t, len(commands) == len(eval.DiceCmds), | ||
fmt.Sprintf("Unexpected number of CLI commands found. expected %d, %d found", len(eval.DiceCmds), len(commands))) | ||
}) | ||
} | ||
|
||
func getCommandDefault(exec *HTTPCommandExecutor) []interface{} { | ||
cmd := HTTPCommand{Command: "COMMAND", Body: map[string]interface{}{"values": []interface{}{}}} | ||
responseValue, _ := exec.FireCommand(cmd) | ||
if responseValue == nil { | ||
return nil | ||
} | ||
var cmds []interface{} | ||
cmds = append(cmds, responseValue.([]interface{})...) | ||
return cmds | ||
} | ||
|
||
func BenchmarkCommandDefault(b *testing.B) { | ||
exec := NewHTTPCommandExecutor() | ||
|
||
b.ResetTimer() | ||
for n := 0; n < b.N; n++ { | ||
commands := getCommandDefault(exec) | ||
if len(commands) <= 0 { | ||
b.Fail() | ||
} | ||
} | ||
} |
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