411147988b
Commit6c86cabbe5
changed the command line interface to behave a lot similar to that of github.com/coreos/toolbox, which makes things easier for those switching over from it. Make it conditional so that only those OS distributors who truly need it may enable it, and restore the previous behaviour as the default. The tests were updated to test the default behaviour that the vast majority of users would be seeing. Ideally, the test suite would be run twice with the migration path turned off and on. However, that would require a more intrusive surgery of the test suite and likely make it slower. It might not be worth the hassle because of the small number of users who should be using the migration path. Note that the copyright and license notices really must use C++-style // line comments, because build constraints can only be preceded by blank lines and other line comments. C-style /* */ block comments can't precede the build constraints. This reverts commitca899c8a56
and parts of commit3aeb7cf288
. [1] go help buildconstraint https://pkg.go.dev/cmd/go#hdr-Build_constraints https://github.com/containers/toolbox/pull/951
134 lines
4 KiB
Bash
134 lines
4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load 'libs/bats-support/load'
|
|
load 'libs/bats-assert/load'
|
|
load 'libs/helpers.bash'
|
|
|
|
setup() {
|
|
_setup_environment
|
|
}
|
|
|
|
@test "help: Try to run toolbox with no command" {
|
|
run $TOOLBOX
|
|
|
|
assert_failure
|
|
assert_line --index 0 "Error: missing command"
|
|
assert_line --index 1 "create Create a new toolbox container"
|
|
assert_line --index 2 "enter Enter an existing toolbox container"
|
|
assert_line --index 3 "list List all existing toolbox containers and images"
|
|
assert_line --index 4 "Run 'toolbox --help' for usage."
|
|
}
|
|
|
|
@test "help: Run command 'help'" {
|
|
if ! command -v man 2>/dev/null; then
|
|
skip "Test works only if man is in PATH"
|
|
fi
|
|
|
|
run $TOOLBOX help
|
|
|
|
assert_success
|
|
assert_line --index 0 --partial "toolbox(1)()"
|
|
}
|
|
|
|
@test "help: Run command 'help' with no man present" {
|
|
if command -v man 2>/dev/null; then
|
|
skip "Test works only if man is not in PATH"
|
|
fi
|
|
|
|
run $TOOLBOX help
|
|
|
|
assert_success
|
|
assert_line --index 0 "toolbox - Tool for containerized command line environments on Linux"
|
|
assert_line --index 1 "Common commands are:"
|
|
assert_line --index 2 "create Create a new toolbox container"
|
|
assert_line --index 3 "enter Enter an existing toolbox container"
|
|
assert_line --index 4 "list List all existing toolbox containers and images"
|
|
assert_line --index 5 "Go to https://github.com/containers/toolbox for further information."
|
|
}
|
|
|
|
@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."
|
|
}
|