coreengine

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Overview

Package coreengine contains the types and functions responsible for managing tests and test execution. This is the primary entry point to the core of the application and should be utilised by the probr library to create, execute and report on tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFeaturePath

func GetFeaturePath(path ...string) string

GetFeaturePath parses a list of strings into a standardized file path

func GodogProbeHandler

func GodogProbeHandler(probe *GodogProbe) (int, *bytes.Buffer, error)

GodogProbeHandler is a general implementation of ProbeHandlerFunc. Based on the output type, the test will either be executed using an in-memory or file output. In both cases, the handler uses the data supplied in GodogProbe to call the underlying GoDog test suite.

func LogScenarioEnd

func LogScenarioEnd(s *godog.Scenario)

LogScenarioEnd logs the name and tags associated with the supplied scenario.

func LogScenarioStart

func LogScenarioStart(s *godog.Scenario)

LogScenarioStart logs the name and tags associated with the supplied scenario.

Types

type GodogProbe

type GodogProbe struct {
	ProbeDescriptor     *ProbeDescriptor
	ProbeInitializer    func(*godog.TestSuiteContext)
	ScenarioInitializer func(*godog.ScenarioContext)
	FeaturePath         string
	Status              *ProbeStatus `json:"status,omitempty"`
	Results             *bytes.Buffer
}

GodogProbe encapsulates the specific data that GoDog feature based tests require in order to run. This structure will be passed to the test handler callback.

type Group

type Group int

Group type describes the group to which the test belongs, e.g. kubernetes, clouddriver, coreengine, etc.

const (
	Kubernetes Group = iota
	CloudDriver
	CoreEngine
)

Group type enumeration

func (Group) String

func (g Group) String() string

type Probe

type Probe interface {
	ProbeInitialize(*godog.TestSuiteContext)
	ScenarioInitialize(*godog.ScenarioContext)
	Name() string
	Path() string
}

Probe is an interface used by probes that are to be exported from any service pack

type ProbeDescriptor

type ProbeDescriptor struct {
	Group Group  `json:"group,omitempty"`
	Name  string `json:"name,omitempty"`
}

ProbeDescriptor describes the specific test case and includes name and group.

type ProbeHandlerFunc

type ProbeHandlerFunc func(t *GodogProbe) (int, *bytes.Buffer, error)

ProbeHandlerFunc describes a callback that should be implemented by test cases in order for ProbeRunner to be able to execute the test case.

type ProbeRunner

type ProbeRunner interface {
	RunProbe(t *GodogProbe) error
}

ProbeRunner describes the interface that should be implemented to support the execution of tests.

type ProbeStatus

type ProbeStatus int

ProbeStatus type describes the status of the test, e.g. Pending, Running, CompleteSuccess, CompleteFail and Error

const (
	Pending ProbeStatus = iota
	Running
	CompleteSuccess
	CompleteFail
	Error
	Excluded
)

ProbeStatus enumeration for the ProbeStatus type.

func (ProbeStatus) String

func (s ProbeStatus) String() string

type ProbeStore

type ProbeStore struct {
	Probes       map[string]*GodogProbe
	FailedProbes map[ProbeStatus]*GodogProbe
	Lock         sync.RWMutex
}

ProbeStore maintains a collection of probes to be run and their status. FailedProbes is an explicit collection of failed probes.

func NewProbeStore

func NewProbeStore() *ProbeStore

NewProbeStore creates a new object to store GodogProbes

func (*ProbeStore) AddProbe

func (ps *ProbeStore) AddProbe(probe *GodogProbe)

AddProbe provided GodogProbe to the ProbeStore.

func (*ProbeStore) ExecAllProbes

func (ps *ProbeStore) ExecAllProbes() (int, error)

ExecAllProbes executes all tests that are present in the ProbeStore.

func (*ProbeStore) ExecProbe

func (ps *ProbeStore) ExecProbe(name string) (int, error)

ExecProbe executes the test identified by the specified name.

func (*ProbeStore) GetProbe

func (ps *ProbeStore) GetProbe(name string) (*GodogProbe, error)

GetProbe returns the test identified by the given name.

func (*ProbeStore) RunProbe

func (ps *ProbeStore) RunProbe(probe *GodogProbe) (int, error)

RunProbe runs the test case described by the supplied Probe. It looks in it's test register (the handlers global variable) for an entry with the same ProbeDescriptor as the supplied test. If found, it uses the provided GodogProbe

Jump to

Keyboard shortcuts

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