Skip to main content

object_test.go

object_test.go - Overview

This file contains a test function TestObjectCommand that tests the functionality of the OBJECT IDLETIME command in the DiceDB server.

Detailed Documentation

TestObjectCommand Function

Purpose: Tests the OBJECT IDLETIME command, which retrieves the idle time of a given key in the database. It checks if the idle time is updated correctly after setting, accessing, and touching the key.

Parameters:

  • t (*testing.T): Testing object for running the test case.

Returns: None

The test cases are defined as a slice of structs, each containing:

  • name (string): Name of the test case.
  • commands ([]string): A slice of Redis commands to execute.
  • expected ([]interface{}); A slice of expected results for each command.
  • assertType ([]string): A slice of strings indicating the type of assertion to use ("equal" or "assert").
  • delay ([]time.Duration): A slice of time durations to wait before executing each command.
  • cleanup ([]string): A slice of commands to execute after the test case is finished.

The function iterates through the test cases, executing the commands, and asserting that the results match the expected values.

Code Examples

None

Getting Started Relevance