testing

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	// Name of the testcase
	Name string
	// Values of gloal variables before run
	Inputs map[string]interface{}
	// Expected values of global vars after run
	Outputs map[string]interface{}
}

Case defines inputs and expected outputs for a run

func (Case) CheckResults

func (c Case) CheckResults(coord *vm.Coordinator) []error

CheckResults compares the global variables of coord with the expected results for c and returns found errors

func (Case) InitializeVariables

func (c Case) InitializeVariables(coord *vm.Coordinator)

InitializeVariables adds the variables required for the testcase to the variables of the given Coordinator

type Script

type Script struct {
	// The absolut path where the test-file was located. Used to retrieve the script files.
	AbsolutePath string
	// Name of the script to run
	Name string
	// Maximum number of iterations for the script (0=infinite)
	Iterations int
	// Maximum number of lines to run from the script (0=infinite)
	MaxLines int
	// the content of the script. If empty, it is loaded from disk at run-time
	Content string
}

Script contains run-options for a script in the test

func (Script) GetCode

func (script Script) GetCode() (string, error)

GetCode returns the code for script either from the script struct itself or from the referenced file

type Test

type Test struct {
	// The absolut path where the test-file was located. Used to retrieve the script files.
	AbsolutePath string
	// Scripts to use in this test
	Scripts []Script
	// Cases for this test
	Cases []Case
}

Test defines a test-run

func Parse

func Parse(file []byte, absolutePath string) (Test, error)

Parse parses a yaml file into a Test absolutePath is the path from where the test was loaded scripts are loaded relative to this path

func (Test) CreateVMs

func (t Test) CreateVMs(coord *vm.Coordinator, errF vm.ErrorHandlerFunc) ([]*vm.YololVM, error)

CreateVMs creates and sets up the required vms for this test coord is the coordinato to use with the VMs Run() has been called on the returned VMs, but they are paused until coord.Run() is called The error handler of the VMs is set to errF

func (Test) Run

func (t Test) Run(caseCallback func(c Case)) []error

Run runs a the given test and return found errors caseCallback is called before executing a case. Can be used for logging. Main method of the test class

Jump to

Keyboard shortcuts

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