Documentation ¶
Index ¶
- Variables
- func MakeDeb(entries []TarEntry) ([]byte, error)
- func MustMakeDeb(entries []TarEntry) []byte
- func Permutations[S ~[]E, E any](s S) []S
- func PrefixEachLine(text string, prefix string) string
- func Reindent(in string) []byte
- func TreeDump(dir string) map[string]string
- func TreeDumpEntry(entry *fsutil.Entry) string
- type BaseTest
- type FakeCmd
- type PGPKeyData
- type TarEntry
- type TestArchive
- type TestPackage
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 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 OtherPackageEntries = []TarEntry{ Dir(0755, "./"), Reg(0644, "./file", "masfdko"), }
var PGPKeys = map[string]*PGPKeyData{
"key-ubuntu-2018": {
ID: "871920D1991BC93C",
PubKeyArmor: pubKeyUbuntu2018Armor,
},
"key1": {
ID: "854BAF1AA9D76600",
PubKeyArmor: pubKey1Armor,
PrivKeyArmor: privKey1Armor,
},
"key2": {
ID: "9568570379BF1F43",
PubKeyArmor: pubKey2Armor,
PrivKeyArmor: privKey2Armor,
},
}
var PackageData = map[string][]byte{}
var TestPackageEntries = []TarEntry{ Dir(0755, "./"), Dir(0755, "./dir/"), Reg(0644, "./dir/file", "12u3q0wej ajsd"), Reg(0644, "./dir/other-file", "kasjdf0"), Dir(0755, "./dir/nested/"), Reg(0644, "./dir/nested/file", "0jqei"), Reg(0644, "./dir/nested/other-file", "1"), Dir(0755, "./dir/several/"), Dir(0755, "./dir/several/levels/"), Dir(0755, "./dir/several/levels/deep/"), Reg(0644, "./dir/several/levels/deep/file", "129i381 "), Dir(0755, "./other-dir/"), Dir(01777, "./parent/"), Dir(0764, "./parent/permissions/"), Reg(0755, "./parent/permissions/file", "ajse0"), }
Functions ¶
func MustMakeDeb ¶ added in v0.8.1
func Permutations ¶ added in v0.10.0
func Permutations[S ~[]E, E any](s S) []S
func PrefixEachLine ¶ added in v0.9.0
PrefixEachLine indents each line in the provided string with the prefix.
func Reindent ¶
Reindent deindents the provided string and replaces tabs with spaces so yaml inlined into tests works properly when decoded.
func TreeDumpEntry ¶ added in v0.10.0
TreeDumpEntry the file information in the same format as testutil.TreeDump.
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 pebble tests.
func (*BaseTest) AddCleanup ¶
func (s *BaseTest) AddCleanup(f func())
AddCleanup adds a new cleanup function to the test
func (*BaseTest) SetUpTest ¶
func (s *BaseTest) SetUpTest(c *check.C)
SetUpTest prepares the cleanup
func (*BaseTest) TearDownTest ¶
func (s *BaseTest) TearDownTest(c *check.C)
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
type PGPKeyData ¶ added in v0.9.0
type TarEntry ¶
func Dir ¶ added in v0.8.1
Dir is a shortcut for creating a directory TarEntry structure (with tar.Typeflag set to tar.TypeDir). Dir stands for "DIRectory".
type TestArchive ¶ added in v1.0.0
type TestArchive struct { Opts archive.Options Packages map[string]TestPackage }
func (*TestArchive) Exists ¶ added in v1.0.0
func (a *TestArchive) Exists(pkg string) bool
func (*TestArchive) Fetch ¶ added in v1.0.0
func (a *TestArchive) Fetch(pkgName string) (io.ReadCloser, *archive.PackageInfo, error)
func (*TestArchive) Info ¶ added in v1.0.0
func (a *TestArchive) Info(pkgName string) (*archive.PackageInfo, error)
func (*TestArchive) Options ¶ added in v1.0.0
func (a *TestArchive) Options() *archive.Options