Documentation
¶
Overview ¶
Package clitest runs the sitrep program in a throwaway HOME, through scenarios of commands, and compares what it printed and left behind with golden files. The scenarios were first run against the last bash version of the program (the git tag bash-final), and their golden files hold what the two agreed on, except where the Go program was changed on purpose since.
Index ¶
- func Golden(t *testing.T, name string, scenario Scenario, goRunner Runner, ...)
- func GoldenT(t *testing.T, scenario Scenario, goRunner Runner, norm ...func(Result) Result)
- func Home(t testing.TB) string
- func Path(home, name string) string
- func Put(t testing.TB, home, name, body string) string
- func State(t testing.TB, home string) map[string]File
- type File
- type Result
- type Runner
- type Scenario
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Golden ¶
func Golden(t *testing.T, name string, scenario Scenario, goRunner Runner, norm ...func(Result) Result)
Golden runs the scenario with the Go program only and compares what it saw (each result, then the state files) with testdata/<name>.golden, or rewrites that file with -update-golden. Review the diff of a rewritten file as carefully as a change of code.
func GoldenT ¶
GoldenT is Golden with the file named after the test: its name with the characters that are not letters, digits or underscores replaced by underscores.
func Path ¶
Path is where the program keeps the file with this name of the old flat layout (<id>.txt, .<id>.state, inbox.queue) in a home. Scenarios are written with the flat names, and the program keeps a folder for each session.
func Put ¶
Put writes a file named as in the old flat layout where the program looks for it, making its folder, and returns the path.
func State ¶
State reads every regular file of the state, by the name it has in the old flat layout, with its mode and its content, in which the HOME is written as $HOME. The Go layout (sessions/<id>/<file>) is read as the flat names, so both are compared as one. A leftover temporary file (.sitrep.*) is kept under its own name, so a run that leaks one is a difference; the random part is dropped. Lock files are left out: they are not part of the state. Anything unexpected (a folder in the root, a file in a session folder that is not one of ours) is kept under its path, so that it is a difference too.