expireat_test.go
expireat_test.go - Overview
This file contains tests for the EXPIREAT
command in the Ironhawk database. It tests various scenarios, including setting expiration times, handling non-existent keys, and using NX
, XX
, GT
, and LT
options.
Detailed Documentation
TestEXPIREAT
Function
Purpose: Tests the functionality of the EXPIREAT
command with different scenarios and options.
Parameters:
t
(*testing.T): Testing object for running test cases.
Returns:
- None
The function defines a series of test cases, each consisting of:
name
(string): A descriptive name for the test case.commands
([]string): A slice of strings representing the commands to be executed.expected
([]interface{}); A slice of interfaces representing the expected results for each command.delay
([]time.Duration, optional): A slice oftime.Duration
values, used to introduce delays between commands.
The function iterates through the test cases, executes the commands, and verifies that the actual results match the expected results.
Test cases cover scenarios such as:
- Setting expiration using
EXPIREAT
. - Checking key expiration.
- Handling
EXPIREAT
with non-existent keys. - Using past expiration times.
- Invalid
EXPIREAT
syntax. - Using the
NX
option (set expiration only if the key has no expiration time). - Using the
XX
option (set expiration only if the key already has an expiration time). - Using the
GT
option (set expiration only if the new expiration time is greater than the current one). - Using the
LT
option (set expiration only if the new expiration time is less than the current one). - Combining
NX/XX
withLT/GT
(which should result in an error). - Testing key existence after expiration with
NX
. - Invalid command option tests.
Code Examples
N/A