toolbox/test/system/002-help.bats
Ondřej Míchal 6c86cabbe5 cmd/root: Make 'toolbox' create or fall back to a container if possible
This makes 'toolbox', without any commands specified, behave a lot like
'toolbox enter'. When there aren't any toolbox containers, it will
offer to create a new container matching the same parameters passed to
the command. If there's just one toolbox container available, then it
will fall back to it.

This makes the command line interface a lot similar to that of
github.com/coreos/toolbox, which makes things easier for those
switching over from it.

Some changes by Debarshi Ray.

https://github.com/containers/toolbox/pull/811
2021-06-29 15:27:56 +02:00

99 lines
2.9 KiB
Bash

#!/usr/bin/env bats
load 'libs/bats-support/load'
load 'libs/bats-assert/load'
load 'libs/helpers.bash'
@test "help: Run command 'help'" {
run $TOOLBOX help
assert_success
assert_output --partial "toolbox - Tool for containerized command line environments on Linux"
}
@test "help: Use flag '--help' (it should show usage screen)" {
run $TOOLBOX --help
assert_success
assert_output --partial "toolbox - Tool for containerized command line environments on Linux"
}
@test "help: Try to run toolbox with non-existent command (shows usage screen)" {
run $TOOLBOX foo
assert_failure
assert_line --index 0 "Error: unknown command \"foo\" for \"toolbox\""
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run toolbox with non-existent flag (shows usage screen)" {
run $TOOLBOX --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox create' with non-existent flag (shows usage screen)" {
run $TOOLBOX create --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox enter' with non-existent flag (shows usage screen)" {
run $TOOLBOX enter --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox help' with non-existent flag (shows usage screen)" {
run $TOOLBOX help --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox init-container' with non-existent flag (shows usage screen)" {
run $TOOLBOX init-container --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox list' with non-existent flag (shows usage screen)" {
run $TOOLBOX list --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox rm' with non-existent flag (shows usage screen)" {
run $TOOLBOX rm --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox rmi' with non-existent flag (shows usage screen)" {
run $TOOLBOX rmi --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}
@test "help: Try to run 'toolbox run' with non-existent flag (shows usage screen)" {
run $TOOLBOX run --foo
assert_failure
assert_line --index 0 "Error: unknown flag: --foo"
assert_line --index 1 "Run 'toolbox --help' for usage."
}