redis

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Venom - Executor Redis

Step to execute command into Redis

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

Input

In your yaml file, you can use:

  • context: required. Must contains dialURL property. DialURL connects to a Redis server at the given URL using the Redis URI scheme. URLs should follow the draft IANA specification for the scheme (https://www.iana.org/assignments/uri-schemes/prov/redis).
  • commands: an array of Redis command
  • path: a file which contains a series of Redis command. See example below.

If path property is filled, commands property will be ignored.

name: My Redis testsuite
testcases:
- name: Commands_Test_Case
  context:
    dialURL: "redis://user:secret@localhost:6379/0"
    type: redis
  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: File_Test_Case
  context:
      dialURL: "redis://localhost:6379/0"
      type: redis
  steps:
  - type: redis
    commands:
        - FLUSHALL
  - type: redis
    path: testredis/commands.txt
    assertions:
        - result.commands.commands0.response ShouldEqual OK
        - result.commands.commands1.response ShouldEqual bar
        - result.commands.commands2.response.response0 ShouldEqual foo

File is read line by line and each command is split by strings.Fields method

SET Foo Bar
SET bar beez
SET Bar {"foo" : "bar", "poo" : ["lol", "lil", "greez"]}
Keys *

Output

result.executor
result.commands
  • result.executor.commands contains the list of Redis command

  • result.executor.FilePath contains the path of file

  • 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

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 {
	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) GetDefaultAssertions

func (e Executor) GetDefaultAssertions() venom.StepAssertions

GetDefaultAssertions return the default assertions of the executor.

func (Executor) Run

func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step venom.TestStep, workdir string) (venom.ExecutorResult, error)

Run execute TestStep

func (Executor) ZeroValueResult

func (Executor) ZeroValueResult() venom.ExecutorResult

ZeroValueResult return an empty implemtation of this executor result

type Result

type Result struct {
	Executor Executor  `json:"executor,omitempty" yaml:"executor,omitempty"`
	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