Documentation ¶
Index ¶
Constants ¶
const DefaultText string = `
Some text.
`
const PackageYamlText string = `
name: package-name
title: PackageTitle
author: package-author
`
const TIMESTAMP_REGEX string = `\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?([+-]\d{2}:\d{2})?[Zz]?`
Variables ¶
var BootCmdEquals Checker = &bootCmdEqualsChecker{ &CheckerInfo{Name: "BootCmdEquals", Params: []string{"obtained", "bootcmd", "env"}}, }
The BootCmdEquals checker verifies that the bootCmd string (possibly with --env prefixes) matches the expected boot command and environment variables. Three arguments are required to the right of the checker: - bootCmd string that contains only the bootcmd without --env prefixes - env map[string]string that defines expected environment variables - soft bool that switches between '=' (when false) and '?=' (when true) operator
For example:
c.Assert("--env=A=1 /node server.js", BootCmdEquals, "/node server.js", map[string]string{"A": "1"}, true)
var CmdOutputMatches Checker = &cmdOutputMatchesChecker{ &CheckerInfo{Name: "CmdOutputMatches", Params: []string{"cmd", "expected"}}, }
The CmdOutputMatches checker invokes bash command and checks if stdout matches.
For example:
c.Check([]string{"echo", "Hello!"}, CmdOutputMatches, "Hello!")
var ContainsArray Checker = &containsArrayChecker{ &CheckerInfo{Name: "ContainsArray", Params: []string{"obtained", "subarray"}}, }
The ContainsArray checker verifies that the obtained array contains the expected subarray.
For example:
c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{"a", "b"}) # TRUE c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{"b", "c"}) # TRUE c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{"b"}) # TRUE c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{"c", "b", "a"}) # FALSE c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{"a", "c"}) # FALSE c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{"x"}) # FALSE c.Assert([]string{"a", "b", "c"}, ContainsArray, []string{}) # FALSE
var DirEquals Checker = &dirEqualsChecker{ &CheckerInfo{Name: "DirEquals", Params: []string{"obtained", "expected"}}, }
DirEquals checker checks that given directory contains exactly given files with given content. Argument 'expected' must be a map[string]interface{} where key is path of the file and value is one of type:
- string - file content must match exactly for checker to succed
- func(string)error- file content is passed to this function and it must return nil for checker to succeed
For example:
c.Assert("/tmp/mydir", DirEquals, map[string]string{"/file01.txt": "Exact content"}) c.Assert("/tmp/mydir", DirEquals, map[string]string{"/file01.txt": func(val string)error{return nil}})
var FileMatches Checker = &fileMatchesChecker{ &CheckerInfo{Name: "FileMatches", Params: []string{"obtained", "expected"}}, }
FileMatches checker checks that given file contains given regexp.
For example:
c.Assert("/tmp/myfile", FileMatches, "Part of the content.+")
var MatchesMultiline Checker = &matchesMultilineChecker{ &CheckerInfo{Name: "Matches", Params: []string{"value", "regex"}}, }
The MatchesMultiline checker verifies that the string provided as the obtained value (or the string resulting from obtained.String()) matches the regular expression provided and is matched against multiline string.
For example:
c.Assert(v, Matches, "perm.*denied")
var TarGzEquals Checker = &tarGzEqualsChecker{ &CheckerInfo{Name: "TarGzEquals", Params: []string{"obtained", "expected"}}, }
TarGzEquals checker checks that given tar.gz archive contains exactly given files with given content. Argument 'expected' must be a map[string]interface{} where key is path of the file and value is one of type:
- string - file content must match exactly for checker to succed
- func(string)error- file content is passed to this function and it must return nil for checker to succeed
For example:
c.Assert("/tmp/archive.tar.gz", TarGzEquals, map[string]string{"/file01.txt": "Exact content"}) c.Assert("/tmp/archive.tar.gz", TarGzEquals, map[string]string{"/file01.txt": func(val string)error{return nil}})
Functions ¶
func CheckBootCmd ¶
func ClearDirectory ¶
func ClearDirectory(directory string)
func FixIndent ¶
FixIndent moves the inline yaml content to the very left. This way we are able to write inline yaml content that is nicely aligned with other code.
func MockGitHubApiServer ¶
func PrepareFiles ¶
PrepareFiles realizes map[filepath]content into given directory. E.g. directory = /tmp/sample, files = {"/file01.txt" => "Foo Bar"} will result in
/tmp/sample/
|- file01.txt
where file01.txt will contain text content of "Foo Bar".
Types ¶
This section is empty.