Skip to main content

decrby_test.go

decrby_test.go - Overview

This file contains a test suite for the DECRBY command in the Ironhawk database.

Detailed Documentation

TestDECRBY Function

Purpose: Tests the functionality of the DECRBY command, which decrements the value of a key by a specified amount.

Parameters:

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

Returns:

  • None

The function defines a series of test cases, each consisting of a name, a list of commands to execute, and a list of expected results. It then iterates through the test cases, executing the commands and comparing the actual results with the expected results. The getLocalConnection function is used to establish a connection to a local database instance. The runTestcases function executes the commands against the database and compares results.

// Example test case
{
name: "DECRBY",
commands: [
"SET key1 5",
"DECRBY key1 2",
"DECRBY key1 2",
"DECRBY key1 1",
"DECRBY key1 1",
],
expected: [
"OK",
3,
1,
0,
-1,
],
}