cli/command/context: context ls: always show current context
if a context is set (e.g. through DOCKER_CONTEXT or the CLI config file), but
wasn't found, then a "stub" context is added, including an error message that
the context doesn't exist.
DOCKER_CONTEXT=nosuchcontext docker context ls
NAME DESCRIPTION DOCKER ENDPOINT ERROR
default Current DOCKER_HOST based configuration unix:///var/run/docker.sock
nosuchcontext * context "nosuchcontext": context not found: …
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -39,3 +39,11 @@ func TestListQuiet(t *testing.T) {
|
||||
assert.NilError(t, runList(cli, &listOptions{quiet: true}))
|
||||
golden.Assert(t, cli.OutBuffer().String(), "quiet-list.golden")
|
||||
}
|
||||
|
||||
func TestListError(t *testing.T) {
|
||||
cli := makeFakeCli(t)
|
||||
cli.SetCurrentContext("nosuchcontext")
|
||||
cli.OutBuffer().Reset()
|
||||
assert.NilError(t, runList(cli, &listOptions{}))
|
||||
golden.Assert(t, cli.OutBuffer().String(), "list-with-error.golden")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user