Documentation
¶
Overview ¶
Package consoletest runs a real lockfile console in the test process: lockkit's console.Run on lockfile's backend, a local source, plugins built from sandbox/testdata, a scripted human and a real socket in the test's private runtime directory.
Index ¶
- func SameUserIsolation(t testing.TB) *console.IsolationEnv
- type Console
- type Options
- type Plugin
- type ScriptIO
- func (s *ScriptIO) Ask(ctx context.Context, prompt string, _ time.Duration) (string, bool)
- func (s *ScriptIO) AskSecret(context.Context, string) ([]byte, error)
- func (s *ScriptIO) Lines() int
- func (s *ScriptIO) Output() string
- func (s *ScriptIO) OutputFrom(n int) string
- func (s *ScriptIO) Println(l string)
- func (s *ScriptIO) Push(answers ...string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SameUserIsolation ¶
func SameUserIsolation(t testing.TB) *console.IsolationEnv
SameUserIsolation lets a test console run in the test's own account (lockkit's AllowSameUser, a test-only switch), with its runtime dir in a fresh short directory under /tmp (socket path length).
Types ¶
type Console ¶
type Console struct {
IO *ScriptIO
Socket string
Work string
Root string
Profile string
SharedDir string
// PluginDir is the plugin store (tests tamper with it).
PluginDir string
// StartLines is how many lines the console printed before it listened
// (start-up: isolation, policy review, status).
StartLines int
// contains filtered or unexported fields
}
Console is a running test console.
type Options ¶
type Options struct {
// Answers script the human: the policy approval first, then each
// decision.
Answers []string
Plugins []Plugin
// Files are created in the local source, by key.
Files map[string]string
// Profile is extra TOML for the profile "samples" (local source,
// prefix "invoices/", answer_quantum "1s" unless set here).
Profile string
// Path replaces the local source's root (a missing one makes every
// fetch fail).
Path string
Backend func(*backend.Options)
// Shared runs the console as in a separated setup: its socket in a
// shared directory (mode 2750, this process's group) and its own uid
// faked as another account's, so that this process is served only as
// a client, and only while Clients (nil: always) allows it.
Clients func() bool
// Hub runs the console in hub mode.
Hub console.HubOptions
}
Options shape a test console.
type Plugin ¶
Plugin is a test plugin to install: Name is qualified ("test.answer1", "acme/test.answer0"); Binary is the sandbox/testdata/plugins directory (the name's last dot part when empty).
type ScriptIO ¶
type ScriptIO struct {
// contains filtered or unexported fields
}
ScriptIO answers the console's prompts from a script and records everything the console prints.
func NewScriptIO ¶
NewScriptIO answers the prompts with answers, in order.
func (*ScriptIO) OutputFrom ¶
OutputFrom is what was printed from line n on.