jsondebug_test.go
jsondebug_test.go - Overview
This file contains integration tests for the JSON.DEBUG MEMORY
command, verifying its functionality with different JSON structures and paths.
Detailed Documentation
TestJSONDEBUG
Function
Purpose: Tests the JSON.DEBUG MEMORY
command with various JSON payloads and paths to check memory usage.
Parameters:
t
(*testing.T): Testing object for running the test.
Returns:
- None
The test cases cover scenarios such as:
- No path specified.
- Valid single path specified.
- Multiple valid paths specified.
- Single path for array JSON.
- Multiple paths for array JSON.
- All paths for array JSON (using slice notation).
The function iterates through a set of test cases, each defining a name, a series of commands to execute, and the expected results. It uses client.FireString
to execute commands and assert.Equal
to verify results against expected values. Finally, it flushes the database (FLUSHDB
) to clean up after the tests.
Test Cases Structure
The testCases
variable is a slice of structs, where each struct represents a test case. Each test case has the following fields:
name
(string): Name of the test case.commands
([]string): A slice of strings representing the commands to execute for the test case.expected
([]interface<>): A slice of interfaces representing the expected results for each command.
Code Examples
There is no specific code example necessary as the entire file is a test suite.