redis

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 3

README

Venom - Executor Redis

Step to execute command into Redis

Use case: your software need to make call to a Redis.

Input

The following inputs are available:

  • commands: an array of Redis command
  • path: a file which contains a series of Redis command. If path property is filled, commands property will be ignored.
  • dialURL: Redis server URL

URL should follow the draft IANA specification for the scheme (https://www.iana.org/assignments/uri-schemes/prov/redis). If you have multiple testcases or steps that use the same Redis URL you can define the dialURL setting once as a testsuite variable.

Commands file is read line by line and each command is split by [strings.Fields](https://golang.org/pkg/strings/#Fields) method

```text
SET Foo Bar
SET bar beez
SET Bar {"foo" : "bar", "poo" : ["lol", "lil", "greez"]}
Keys *
name: Redis testsuite
vars: 
  redis.dialURL: "redis://localhost:6379/0"
  
testcases:
- name: test-commands
  steps:
  - type: redis
    commands:
        - FLUSHALL
  - type: redis
    commands:
        - SET foo bar
        - GET foo
        - KEYS *
    assertions:
        - result.commands.commands0.response ShouldEqual OK
        - result.commands.commands1.response ShouldEqual bar
        - result.commands.commands2.response.response0 ShouldEqual foo
  - type: redis
    commands:
        - KEYS *
    assertions:
        - result.commands.commands0.response.response0 ShouldEqual foo

- name: test-commands-from-file
  steps:
  - type: redis
    path: testredis/commands.txt
    dialURL: "redis://localhost:6379/0" # The global dialURL is overridden by this setting
    assertions:
        - result.commands.commands0.response ShouldEqual OK
        - result.commands.commands1.response ShouldEqual bar
        - result.commands.commands2.response.response0 ShouldEqual foo

Output

The executor returns a result object that contains the executed Redis command.

  • result.commands contains the list of executed Redis command
  • result.commands.commandI.response represents the response of Redis command. It can be an array or a string, depends of Redis command

Examples

More example can be used in the tests folder of this repository.

Documentation

Index

Constants

View Source
const Name = "redis"

Name of executor

Variables

This section is empty.

Functions

func New

func New() venom.Executor

New returns a new Executor

Types

type Command

type Command struct {
	Name     string        `json:"name,omitempty" yaml:"name,omitempty"`
	Args     []interface{} `json:"args,omitempty" yaml:"args,omitempty"`
	Response interface{}   `json:"response,omitempty" yaml:"response,omitempty"`
}

Command represents a redis command and the result

type Executor

type Executor struct {
	DialURL  string   `json:"dialURL,omitempty" yaml:"dialURL,omitempty" mapstructure:"dialURL"`
	Commands []string `json:"commands,omitempty" yaml:"commands,omitempty"`
	FilePath string   `json:"path,omitempty" yaml:"path,omitempty" mapstructure:"path"`
}

Executor represents the redis executor

func (Executor) Run

func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, error)

Run execute TestStep

func (Executor) ZeroValueResult

func (Executor) ZeroValueResult() interface{}

ZeroValueResult return an empty implementation of this executor result

type Result

type Result struct {
	Commands []Command `json:"commands,omitempty" yaml:"commands,omitempty"`
}

Result represents a step result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL