ttl_test.go
ttl_test.go - Overview
This file contains tests for the TTL
command in the Ironhawk database. It verifies the functionality of retrieving the time-to-live of keys with and without expiry times.
Detailed Documentation
TestTTL
Function
Purpose: Tests the functionality of the TTL
command, including cases with existing and non-existent keys, expiry times, deletion, persistence, and multiple updates.
Parameters:
t
(*testing.T): Testing object for running test cases.
Returns:
- None
Test Cases:
The testCases
variable is a slice of TestCase
structs, where each test case includes:
name
(string): Name of the test case.commands
([]string): A slice of commands to execute.expected
([]interface<>): A slice of expected results for each command.delay
([]time.Duration): A slice of durations to wait between commands.
The test cases cover scenarios such as:
- Retrieving TTL of a simple value with an expiry.
- Retrieving TTL of a non-existent key.
- Handling negative expiry values.
- Retrieving TTL of a key without an expiry.
- Retrieving TTL after deleting a key.
- Multiple TTL updates.
- TTL with persistence.
- TTL with expiry and expired key.
The runTestcases
function (not defined in this file) is assumed to execute the test cases against a local connection.