runtime

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitCode  = "ExitCode"
	Stdout    = "Stdout"
	Stderr    = "Stderr"
	LineCount = "LineCount"
)

Constants for defining the various tested properties

View Source
const WorkerCountMultiplicator = 5

Variables

This section is empty.

Functions

func Start

func Start(tests []TestCase, maxConcurrent int) <-chan TestResult

Start starts the given test suite and executes all tests maxConcurrent configures the amount of go routines which will be started

Types

type CommandResult

type CommandResult struct {
	Status            ResultStatus
	Stdout            string
	Stderr            string
	ExitCode          int
	FailureProperties []string
	Error             error
}

CommandResult holds the result for a specific test

type CommandUnderTest

type CommandUnderTest struct {
	Cmd      string
	Env      map[string]string
	Dir      string
	Timeout  string
	Retries  int
	Interval string
}

CommandUnderTest represents the command under test

func (*CommandUnderTest) GetRetries added in v1.0.0

func (c *CommandUnderTest) GetRetries() int

GetRetries returns the retries of the command

type Expected

type Expected struct {
	Stdout    ExpectedOut
	Stderr    ExpectedOut
	LineCount int
	ExitCode  int
}

Expected is the expected output of the command under test

type ExpectedOut

type ExpectedOut struct {
	Contains    []string       `yaml:"contains,omitempty"`
	Lines       map[int]string `yaml:"lines,omitempty"`
	Exactly     string         `yaml:"exactly,omitempty"`
	LineCount   int            `yaml:"line-count,omitempty"`
	NotContains []string       `yaml:"not-contains,omitempty"`
}

ExpectedOut represents the assertions on stdout and stderr

type ResultStatus

type ResultStatus int

ResultStatus represents the status code of a test result

const (
	//Success status
	Success ResultStatus = iota
	// Failed status
	Failed
	// Skipped status
	Skipped
)

Result status codes

type TestCase

type TestCase struct {
	Title    string
	Command  CommandUnderTest
	Expected Expected
	Result   CommandResult
}

TestCase represents a test case which will be executed by the runtime

type TestConfig

type TestConfig struct {
	Env      map[string]string
	Dir      string
	Timeout  string
	Retries  int
	Interval string
}

TestConfig represents the configuration for a test

type TestResult

type TestResult struct {
	TestCase         TestCase
	ValidationResult ValidationResult
	FailedProperty   string
	Tries            int
}

TestResult represents the TestCase and the ValidationResult

func Validate

func Validate(test TestCase) TestResult

Validate validates the test results with the expected values The test should hold the result and expected to validate the result

type ValidationResult

type ValidationResult struct {
	Success bool
	Diff    string
}

ValidationResult will be returned after the validation was executed

Jump to

Keyboard shortcuts

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