Documentation ¶
Index ¶
- type AssertionResult
- type Command
- type DirectoryAssertion
- type Expectations
- type FileAssertion
- type FileExtension
- type FileSystemAssertion
- type Launcher
- type OutputAssertion
- type OutputAssertions
- type Preconditions
- type ReportBlock
- type ReportEntry
- type ReportEntryType
- type Reporter
- type Spec
- type StatusAssertion
- type TestExecutionReport
- type TestPlan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssertionResult ¶
type AssertionResult struct {
// contains filtered or unexported fields
}
AssertionResult is the container of verification results.
func (*AssertionResult) Description ¶
func (r *AssertionResult) Description() string
Description is the textual representation of the assertion.
func (*AssertionResult) Errors ¶
func (r *AssertionResult) Errors() []error
Errors returns the errors list.
func (*AssertionResult) Success ¶
func (r *AssertionResult) Success() bool
Success returns if an assertion completed with no error.
type Command ¶
type Command struct { WorkingDir string `yaml:"working_dir"` Cli string `yaml:"cli"` Exe string `yaml:"exe"` Env map[string]string // added to exe Extension FileExtension `yaml:"ext"` Args []string `yaml:"args"` }
Command represents the command under test.
type DirectoryAssertion ¶
type DirectoryAssertion struct { Path string `yaml:"path"` Exists bool `yaml:"exists"` EqualsTo string `yaml:"equals_to"` ContainsAny []string `yaml:"contains_any"` ContainsAll []string `yaml:"contains_all"` ContainsExactly []string `yaml:"contains_exactly"` }
DirectoryAssertion is an assertion on a given directory.
type Expectations ¶
type Expectations struct { StatusAssertion StatusAssertion `yaml:"status"` OutputAssertions OutputAssertions `yaml:"output"` FileSystemAssertions []FileSystemAssertion `yaml:"fs"` }
Expectations is the aggregate of the final assertions on the command executed.
type FileAssertion ¶
type FileAssertion struct { Path string `yaml:"path"` // aggiunta a path Extension FileExtension `yaml:"ext"` Exists bool `yaml:"exists"` EqualsTo string `yaml:"equals_to"` TextEqualsTo string `yaml:"text_equals_to"` ContainsAny []string `yaml:"contains_any"` ContainsAll []string `yaml:"contains_all"` }
FileAssertion is an assertion on a given file.
type FileExtension ¶
FileExtension is added as suffix to file assertions' path and command's exe values based on runtime.GOOS
type FileSystemAssertion ¶
type FileSystemAssertion struct { File string `yaml:"file"` // aggiunta a file Extension FileExtension `yaml:"ext"` Directory string `yaml:"directory"` Exists *bool `yaml:"exists"` EqualsTo string `yaml:"equals_to"` // Only for files TextEqualsTo string `yaml:"text_equals_to"` ContainsAny []string `yaml:"contains_any"` ContainsAll []string `yaml:"contains_all"` ContainsExactly []string `yaml:"contains_exactly"` }
FileSystemAssertion is an assertion on files and directories.
type Launcher ¶
type Launcher struct {
// contains filtered or unexported fields
}
Launcher checks the results respect expectations.
func NewLauncher ¶
func NewLauncher() *Launcher
NewLauncher creates a default implementation for Launcher.
func (*Launcher) Execute ¶
func (l *Launcher) Execute(plan TestPlan) *TestExecutionReport
Execute run tests loaded from a TestPlan.
func (*Launcher) ExecuteFile ¶
func (l *Launcher) ExecuteFile(path string) *TestExecutionReport
ExecuteFile run tests loaded from a file.
type OutputAssertion ¶
type OutputAssertion struct { EqualsTo string `yaml:"equals_to"` EqualsToFile string `yaml:"equals_to_file"` // output is trimmed StartsWith string `yaml:"starts_with"` // output is trimmed EndsWith string `yaml:"ends_with"` IsEmpty *bool `yaml:"is_empty"` ContainsAny []string `yaml:"contains_any"` ContainsAll []string `yaml:"contains_all"` ContainsNone []string `yaml:"contains_none"` // contains filtered or unexported fields }
OutputAssertion is an assertion on the output of a command: namely standard output and standard error.
type OutputAssertions ¶
type OutputAssertions struct { Stdout OutputAssertion `yaml:"stdout"` Stderr OutputAssertion `yaml:"stderr"` }
OutputAssertions is the aggregate of stdout and stderr assertions.
type Preconditions ¶
type Preconditions struct {
FileSystemAssertions []FileSystemAssertion `yaml:"fs"`
}
Preconditions represents the minimal requirements for a plan or a single spec to start.
type ReportBlock ¶
type ReportBlock struct {
// contains filtered or unexported fields
}
ReportBlock is an aggregate of report entries classified on the phase.
func (*ReportBlock) Entries ¶
func (r *ReportBlock) Entries() []ReportEntry
Entries returns the entries of a block.
func (*ReportBlock) Phase ¶
func (r *ReportBlock) Phase() string
Phase returns the phase of a block.
type ReportEntry ¶
type ReportEntry struct {
// contains filtered or unexported fields
}
ReportEntry is a single unit of information in a report.
func (*ReportEntry) Description ¶
func (r *ReportEntry) Description() string
Description is the textual representation of a report entry.
func (*ReportEntry) Errors ¶
func (r *ReportEntry) Errors() []error
Errors returns the errors list in a report entry.
func (*ReportEntry) Kind ¶
func (r *ReportEntry) Kind() ReportEntryType
Kind returns the type of a report entry: error, info, success...
type ReportEntryType ¶
type ReportEntryType int8
ReportEntryType represents the type of a report entry.
const ( // ErrorType is report entry error ErrorType ReportEntryType // InfoType is report entry info InfoType // SuccessType is report entry success SuccessType )
type Reporter ¶
type Reporter interface {
Publish(report *TestExecutionReport) error
}
Reporter is the interface for components publishing the report.
func NewConsoleReporter ¶
func NewConsoleReporter() Reporter
NewConsoleReporter returns a Reporter implementation writing to the stdout.
func NewTestLogsReporter ¶
NewTestLogsReporter returns a Reporter implementation using the testing log.
type Spec ¶
type Spec struct { Description string `yaml:"description"` Preconditions Preconditions `yaml:"preconditions"` Command Command `yaml:"command"` Expectations Expectations `yaml:"expectations"` // contains filtered or unexported fields }
Spec is the single test.
type StatusAssertion ¶
type StatusAssertion struct { EqualsTo string `yaml:"equals_to"` GreaterThan string `yaml:"greater_than"` LesserThan string `yaml:"lesser_than"` }
StatusAssertion represents an assertion on the status code returned from a command.
type TestExecutionReport ¶
type TestExecutionReport struct {
// contains filtered or unexported fields
}
TestExecutionReport is the full report on a test execution
func (*TestExecutionReport) AllErrors ¶
func (r *TestExecutionReport) AllErrors() []error
AllErrors returns all errors in a report, without considering blocks or phases.
func (*TestExecutionReport) Blocks ¶
func (r *TestExecutionReport) Blocks() []*ReportBlock
Blocks returns the blocks list in a full report.
type TestPlan ¶
type TestPlan struct { Preconditions Preconditions `yaml:"preconditions"` Specs map[string]Spec `yaml:"specs"` }
TestPlan represents the full set of tests on a program.