Skip to main content

decr_test.go

decr_test.go - Overview

This file contains a test suite for the DECR command within the ironhawk package. It tests the decrement functionality of a key's value in the database.

Detailed Documentation

TestDECR Function

Purpose: Tests the DECR command to ensure it correctly decrements the value of a key.

Parameters:

  • t (*testing.T): The testing object provided by the Go testing framework.

Returns: None.

testCases := []TestCase{
{
name: "DECR",
commands: []string{"SET key1 2", "DECR key1", "DECR key1", "DECR key1"},
expected: []interface{}{"OK", 1, 0, -1},
},
}

The test case initializes a key "key1" with the value 2, then decrements it three times, expecting the values 1, 0, and -1 respectively.

getLocalConnection Function

Note: This function is not defined in this file.

Purpose: Presumably, this function establishes a connection to a local database instance for testing.

Parameters: None.

Returns: A client object that represents the connection to the local database.

runTestcases Function

Note: This function is not defined in this file.

Purpose: Presumably, this function executes a series of test cases against the database client and validates the results.

Parameters:

  • t (*testing.T): The testing object provided by the Go testing framework.
  • client: A client object representing the connection to the database.
  • testCases ([]TestCase): A slice of TestCase structs, each defining a test case to be executed.

Returns: None.

Getting Started Relevance: YES