Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Contains check.Checker = &containsChecker{ &check.CheckerInfo{Name: "Contains", Params: []string{"container", "elem"}}, }
Contains is a Checker that looks for a elem in a container. The elem can be any object. The container can be an array, slice or string.
var DeepContains check.Checker = &deepContainsChecker{ &check.CheckerInfo{Name: "DeepContains", Params: []string{"container", "elem"}}, }
DeepContains is a Checker that looks for a elem in a container using DeepEqual. The elem can be any object. The container can be an array, slice or string.
var DeepUnsortedMatches check.Checker = &deepUnsortedMatchChecker{ &check.CheckerInfo{Name: "DeepUnsortedMatches", Params: []string{"container1", "container2"}}, }
DeepUnsortedMatches checks if two containers contain the same elements in the same number (but possibly different order) using DeepEqual. The container can be an array, a slice or a map.
var DirEquals check.Checker = &dirContentChecker{ CheckerInfo: &check.CheckerInfo{Name: "DirEquals", Params: []string{"directory", "contents"}}, }
DirEquals verifies that the given directory contains exactly the given contents. Contents should be a slice of strings of the form "drwxr-xr-x filename".
var ErrorIs = &errorIsChecker{ &check.CheckerInfo{Name: "ErrorIs", Params: []string{"error", "target"}}, }
ErrorIs calls errors.Is with the provided arguments.
var FileAbsent check.Checker = &filePresenceChecker{ CheckerInfo: &check.CheckerInfo{Name: "FileAbsent", Params: []string{"filename"}}, present: false, }
FileAbsent verifies that the given file does not exist.
var FileContains check.Checker = &fileContentChecker{ CheckerInfo: &check.CheckerInfo{Name: "FileContains", Params: []string{"filename", "contents"}}, }
FileContains verifies that the given file's content contains the string (or fmt.Stringer) or []byte provided.
var FileEquals check.Checker = &fileContentChecker{ CheckerInfo: &check.CheckerInfo{Name: "FileEquals", Params: []string{"filename", "contents"}}, exact: true, }
FileEquals verifies that the given file's content is equal to the string (or fmt.Stringer) or []byte provided.
var FileMatches check.Checker = &fileContentChecker{ CheckerInfo: &check.CheckerInfo{Name: "FileMatches", Params: []string{"filename", "regex"}}, }
FileMatches verifies that the given file's content matches the string provided.
var FilePresent check.Checker = &filePresenceChecker{ CheckerInfo: &check.CheckerInfo{Name: "FilePresent", Params: []string{"filename"}}, present: true, }
FilePresent verifies that the given file exists.
var IntEqual = &intChecker{CheckerInfo: &check.CheckerInfo{Name: "IntEqual", Params: []string{"a", "b"}}, rel: "=="}
IntEqual checker verifies that one integer is equal to other integer.
For example:
c.Assert(1, IntEqual, 1)
var IntGreaterEqual = &intChecker{CheckerInfo: &check.CheckerInfo{Name: "IntGreaterEqual", Params: []string{"a", "b"}}, rel: ">="}
IntGreaterEqual checker verifies that one integer is greater than or equal to other integer.
For example:
c.Assert(1, IntGreaterEqual, 2)
var IntGreaterThan = &intChecker{CheckerInfo: &check.CheckerInfo{Name: "IntGreaterThan", Params: []string{"a", "b"}}, rel: ">"}
IntGreaterThan checker verifies that one integer is greater than other integer.
For example:
c.Assert(2, IntGreaterThan, 1)
var IntLessEqual = &intChecker{CheckerInfo: &check.CheckerInfo{Name: "IntLessEqual", Params: []string{"a", "b"}}, rel: "<="}
IntLessEqual checker verifies that one integer is less than or equal to other integer.
For example:
c.Assert(1, IntLessEqual, 1)
var IntLessThan = &intChecker{CheckerInfo: &check.CheckerInfo{Name: "IntLessThan", Params: []string{"a", "b"}}, rel: "<"}
IntLessThan checker verifies that one integer is less than other integer.
For example:
c.Assert(1, IntLessThan, 2)
var IntNotEqual = &intChecker{CheckerInfo: &check.CheckerInfo{Name: "IntNotEqual", Params: []string{"a", "b"}}, rel: "!="}
IntNotEqual checker verifies that one integer is not equal to other integer.
For example:
c.Assert(1, IntNotEqual, 2)
var JsonEquals check.Checker = &jsonEqualChecker{ &check.CheckerInfo{Name: "JsonEqual", Params: []string{"obtained", "expected"}}, }
JsonEquals compares the obtained and expected values after having serialized them to JSON and deserialized to a generic any type. This avoids trouble comparing types with unexported fields that otherwise would be problematic to set in external packages.
var SymlinkTargetContains check.Checker = &symlinkTargetChecker{ CheckerInfo: &check.CheckerInfo{Name: "SymlinkTargetContains", Params: []string{"filename", "target"}}, }
SymlinkTargetContains verifies that the given file is a symbolic link whose target contains the provided text.
var SymlinkTargetEquals check.Checker = &symlinkTargetChecker{ CheckerInfo: &check.CheckerInfo{Name: "SymlinkTargetEquals", Params: []string{"filename", "target"}}, exact: true, }
SymlinkTargetEquals verifies that the given file is a symbolic link with the given target.
var SymlinkTargetMatches check.Checker = &symlinkTargetChecker{ CheckerInfo: &check.CheckerInfo{Name: "SymlinkTargetMatches", Params: []string{"filename", "regex"}}, }
SymlinkTargetMatches verifies that the given file is a symbolic link whose target matches the provided regular expression.
Functions ¶
Types ¶
type BaseTest ¶
type BaseTest struct {
// contains filtered or unexported fields
}
BaseTest is a structure used as a base test suite for many of the workshop tests.
func (*BaseTest) AddCleanup ¶
func (s *BaseTest) AddCleanup(f func())
AddCleanup adds a new cleanup function to the test
func (*BaseTest) TearDownTest ¶
TearDownTest cleans up the channel.ini files in case they were changed by the test. It also runs the cleanup handlers
type FakeCmd ¶
type FakeCmd struct {
// contains filtered or unexported fields
}
FakeCmd allows faking commands for testing.
func FakeCommand ¶
FakeCommand adds a faked command. If the basename argument is a command it is added to PATH. If it is an absolute path it is just created there. the caller is responsible for the cleanup in this case.
The command logs all invocations to a dedicated log file. If script is non-empty then it is used as is and the caller is responsible for how the script behaves (exit code and any extra behavior). If script is empty then the command exits successfully without any other side-effect.
func (*FakeCmd) Also ¶
Also fake this command, using the same bindir and log. Useful when you want to check the ordering of things.
func (*FakeCmd) Calls ¶
Calls returns a list of calls that were made to the fake command. of the form:
[][]string{
{"cmd", "arg1", "arg2"}, // first invocation of "cmd"
{"cmd", "arg1", "arg2"}, // second invocation of "cmd"
}
func (*FakeCmd) ForgetCalls ¶
func (cmd *FakeCmd) ForgetCalls()
ForgetCalls purges the list of calls made so far