exec

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: 13 Imported by: 5

README

Venom - Executor Exec

Step used to execute a script

Input

Example


name: Title of TestSuite
testcases:
- name: Check if exit code != 1 and echo command response in less than 1s
  steps:
  - type: exec
    script: echo 'foo'
    assertions:
    - result.code ShouldEqual 0
    - result.timeseconds ShouldBeLessThan 1

Multiline script:

name: Title of TestSuite
testcases:
- name: multiline script
  steps:
  - type: exec
    script: |
            echo "Foo" \
            echo "Bar"

Input:

name: Title of TestSuite
testcases:
- name: with stdin
  steps:
  - type: exec
    stdin: Foo
    script: cat

Explicit command (no shell):

name: Title of TestSuite
testcases:
- name: explicit command
  steps:
  - type: exec
    stdin: "{\"foo\":\"bar\"}"
    command: ["jq", ".foo"]

Output

systemout
systemoutjson
systemerr
systemerrjson
err
code
timeseconds
  • result.timeseconds: duration of execution
  • result.err: if exists, this field contains error details
  • result.systemout: Standard Output of the executed script
  • result.systemoutjson: Standard Output of the executed script parsed as a JSON object
  • result.systemerr: Error output of the executed script
  • result.systemerrjson: Error output of the executed script parsed as a JSON object
  • result.code: Exit code

Default assertion

result.code ShouldEqual 0

Documentation

Index

Constants

View Source
const Name = "exec"

Name for test exec

Variables

This section is empty.

Functions

func New

func New() venom.Executor

New returns a new Test Exec

Types

type Executor

type Executor struct {
	Command []string `json:"command,omitempty" yaml:"command,omitempty"`
	Stdin   *string  `json:"stdin,omitempty" yaml:"stdin,omitempty"`
	Script  *string  `json:"script,omitempty" yaml:"script,omitempty"`
}

Executor represents a Test Exec

func (Executor) GetDefaultAssertions

func (Executor) GetDefaultAssertions() *venom.StepAssertions

GetDefaultAssertions return default assertions for type exec

func (Executor) Run

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

Run execute TestStep of type exec

func (Executor) ZeroValueResult added in v0.17.0

func (Executor) ZeroValueResult() interface{}

ZeroValueResult return an empty implementation of this executor result

type Result

type Result struct {
	Systemout     string      `json:"systemout,omitempty" yaml:"systemout,omitempty"`
	SystemoutJSON interface{} `json:"systemoutjson,omitempty" yaml:"systemoutjson,omitempty"`
	Systemerr     string      `json:"systemerr,omitempty" yaml:"systemerr,omitempty"`
	SystemerrJSON interface{} `json:"systemerrjson,omitempty" yaml:"systemerrjson,omitempty"`
	Err           string      `json:"err,omitempty" yaml:"err,omitempty"`
	Code          string      `json:"code,omitempty" yaml:"code,omitempty"`
	TimeSeconds   float64     `json:"timeseconds,omitempty" yaml:"timeseconds,omitempty"`
}

Result represents a step result

Jump to

Keyboard shortcuts

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