Skip to main content

zcard_test.go

zcard_test.go - Overview

This file contains tests for the ZCARD command, which is used to determine the number of elements in a sorted set.

Detailed Documentation

Function: TestZCARD

Purpose: Tests the functionality of the ZCARD command with various scenarios, including invalid arguments, wrong key types, non-existent keys, and sorted sets with single and multiple elements.

Parameters:

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

Returns:

  • None.

The test cases cover the following scenarios:

  • ZCARD with wrong number of arguments.
  • ZCARD with wrong type of key.
  • ZCARD with non-existent key.
  • ZCARD with sorted set holding single element.
  • ZCARD with sorted set holding multiple elements.

The tests use a local client connection to execute commands and assert the expected results. Each test case is run in a separate subtest. Before each test case, the sorted set myzset and string key string_key are deleted to ensure a clean state.

Code Examples

None.

Getting Started Relevance