main_test.go
main_test.go
- Overview
This file contains integration tests for the DiceDB Ironhawk commands. It defines test cases with commands, expected results, and optional delays, then executes these tests against a DiceDB client.
Detailed Documentation
TestMain
- Purpose: This function is the entry point for running all tests in the package. It initializes the DiceDB configuration and runs the tests.
- Parameters:
m
(*testing.M): Represents the test runner.
- Returns: None
TestCase
- Purpose: Structure to hold the data for a test case.
- Fields:
name
(string): Name of the test case.commands
([]string): List of commands to execute.expected
([]interface{}): List of expected results for each command.delay
([]time.Duration): List of delays to wait before executing each command.
assertEqual
- Purpose: This function asserts that the expected result matches the actual result returned by the DiceDB client. It handles different data types for comparison.
- Parameters:
t
(*testing.T): Testing object for error reporting.expected
(interface{}): The expected result.actual
(*wire.Response): The actual result received from the DiceDB client.
- Returns: None
runTestcases
- Purpose: This function executes a series of test cases against a DiceDB client. It flushes the database before running the tests and asserts the result of each command.
- Parameters:
t
(*testing.T): Testing object for error reporting.client
(*dicedb.Client): The DiceDB client to use for executing commands.testCases
([]TestCase
): List of test cases to execute.
- Returns: None