Skip to main content

hget_test.go

tests/commands/ironhawk/hget_test.go - Overview

This file contains tests for the HGET command in the ironhawk package. It tests various scenarios, including retrieving a value from a hash, attempting to use HGET on a non-hash key, and providing an insufficient number of arguments.

Detailed Documentation

Function: TestHGET

Purpose: Tests the functionality of the HGET command.

Parameters:

  • t (*testing.T): A testing object used for running and reporting test results.

Returns:

  • None

The test cases include:

  • Getting a value for a field stored at a hash key.
  • Getting a hash field on a non-hash key, which should return an error.
  • Getting a hash key with no field argument, which should also return an error.

Type: TestCase

Note: Defined elsewhere, but used within TestHGET. Structure is not defined in the code.

Purpose: Represents a single test case.

Fields (inferred):

  • name (string): Name of the test case.
  • commands ([]string): A slice of commands to execute for the test case.
  • expected ([]interface{}]): A slice of expected results for the commands.

Function: getLocalConnection

Note: Defined elsewhere.

Purpose: Obtains a local client connection.

Parameters:

  • None

Returns:

  • client: A client object (type not defined) representing the local connection.

Function: runTestcases

Note: Defined elsewhere.

Purpose: Executes a series of test cases against a client.

Parameters:

  • t (*testing.T): A testing object for reporting test results.
  • client: A client object to execute the commands against.
  • testCases ([]TestCase): A slice of TestCase structs to execute.

Returns:

  • None

Getting Started Relevance