2020-02-10 15:16:36 +00:00
|
|
|
|
#!/usr/bin/env bats
|
2022-11-29 12:54:13 +00:00
|
|
|
|
#
|
|
|
|
|
# Copyright © 2020 – 2022 Red Hat, Inc.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
#
|
2020-02-10 15:16:36 +00:00
|
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
|
load 'libs/bats-support/load'
|
|
|
|
|
load 'libs/bats-assert/load'
|
2021-05-26 20:12:18 +00:00
|
|
|
|
load 'libs/helpers.bash'
|
2020-02-10 15:16:36 +00:00
|
|
|
|
|
2021-08-03 18:14:22 +00:00
|
|
|
|
setup() {
|
2021-11-11 00:46:21 +00:00
|
|
|
|
_setup_environment
|
2021-08-03 18:14:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-13 13:16:32 +00:00
|
|
|
|
@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."
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
|
@test "help: Run command 'help'" {
|
2021-11-12 20:39:59 +00:00
|
|
|
|
if ! command -v man 2>/dev/null; then
|
2021-11-07 23:03:08 +00:00
|
|
|
|
skip "Test works only if man is in PATH"
|
|
|
|
|
fi
|
|
|
|
|
|
2021-05-26 20:12:18 +00:00
|
|
|
|
run $TOOLBOX help
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2023-01-11 19:19:44 +00:00
|
|
|
|
assert_line --index 0 --partial "toolbox(1)"
|
|
|
|
|
assert_line --index 0 --partial "General Commands Manual"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 10:54:18 +00:00
|
|
|
|
@test "help: Run command 'help' with no man present" {
|
2021-11-12 20:39:59 +00:00
|
|
|
|
if command -v man 2>/dev/null; then
|
2021-07-13 10:54:18 +00:00
|
|
|
|
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."
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
|
@test "help: Use flag '--help' (it should show usage screen)" {
|
2021-05-26 20:12:18 +00:00
|
|
|
|
run $TOOLBOX --help
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_success
|
2021-06-25 23:54:24 +00:00
|
|
|
|
assert_output --partial "toolbox - Tool for containerized command line environments on Linux"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "help: Try to run toolbox with non-existent command (shows usage screen)" {
|
2021-05-26 20:12:18 +00:00
|
|
|
|
run $TOOLBOX foo
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
|
|
assert_failure
|
|
|
|
|
assert_line --index 0 "Error: unknown command \"foo\" for \"toolbox\""
|
|
|
|
|
assert_line --index 1 "Run 'toolbox --help' for usage."
|
2020-02-10 15:16:36 +00:00
|
|
|
|
}
|
2021-06-22 16:51:13 +00:00
|
|
|
|
|
|
|
|
|
@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."
|
|
|
|
|
}
|
2021-06-25 15:51:02 +00:00
|
|
|
|
|
|
|
|
|
@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."
|
|
|
|
|
}
|