Skip to main content

command_rename_test.go

command_rename_test.go - Overview

This file contains test cases for the RENAME command in the DiceDB. These tests verify the functionality of renaming keys within the database, including scenarios where the source key does not exist, the destination key already exists, and renaming a key to itself.

Detailed Documentation

renameKeysTestCases

  • Purpose: This variable defines a slice of test cases for the RENAME command. Each test case includes a name, a series of commands to execute, and the expected results.
  • Type: []struct
    • name: string - The name of the test case.
    • inCmd: []string - A slice of commands to execute.
    • expected: []interface{} - A slice of expected results corresponding to each command.

TestCommandRename

  • Purpose: This function tests the RENAME command by iterating through the renameKeysTestCases, executing the commands, and asserting that the results match the expected values.
  • Parameters:
    • t: *testing.T - A pointer to the testing object, used for reporting test failures.
  • Returns: None

getLocalConnection

  • Purpose: Gets a local connection to the database client (declared in other files).
  • Parameters: None
  • Returns: *Client - Returns a pointer to the Client object.

Getting Started Relevance