getex_test.go
getex_test.go - Overview
This file contains tests for the GETEX
command in the Ironhawk package. It tests various scenarios, including retrieving existing and non-existent keys, using EX
, PX
, PERSIST
, EXAT
, and invalid options with the GETEX
command.
Detailed Documentation
TestGETEX
Function
Purpose: Tests the functionality of the GETEX
command with different options and scenarios.
Parameters:
t
(*testing.T): Testing object for running test cases.
Returns: None
The test cases cover scenarios such as:
- Retrieving a simple value with
GETEX
. - Retrieving a non-existent key.
- Using the
EX
option to set an expiry in seconds. - Using the
PX
option to set an expiry in milliseconds. - Using the
PERSIST
option to remove expiry. - Providing invalid options.
- Providing negative or zero expiry values.
- Providing non-numeric expiry values.
- Using the
PXAT
option with a future timestamp. - Using the
EXAT
option with a past timestamp.
The test cases are defined as a slice of TestCase
structs, each containing:
name
: The name of the test case.commands
: A slice of strings representing the commands to execute.expected
: A slice of interfaces representing the expected results for each command.delay
: An optional slice oftime.Duration
specifying delays to introduce between commands (used for testing expiry).
The test function iterates through each test case, executes the commands against a local DiceDB connection, and compares the actual results with the expected results.
Code Examples
N/A