2020-07-27 13:35:17 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load 'libs/bats-support/load'
|
|
|
|
load 'libs/bats-assert/load'
|
|
|
|
load 'libs/helpers'
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
cleanup_containers
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
cleanup_containers
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "run: Try to run echo 'Hello World' with no containers created" {
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX run echo "Hello World"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_failure
|
|
|
|
assert_line --index 0 --regexp 'Error: container .* not found'
|
|
|
|
assert_output --partial "Run 'toolbox --help' for usage."
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "run: Run echo 'Hello World' inside of the default container" {
|
|
|
|
create_default_container
|
|
|
|
|
2021-07-16 18:32:06 +00:00
|
|
|
run $TOOLBOX --verbose run echo -n "Hello World"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-07-16 18:32:06 +00:00
|
|
|
assert_line --index $((${#lines[@]}-1)) "Hello World"
|
2020-07-27 13:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "run: Run echo 'Hello World' inside a container after being stopped" {
|
|
|
|
create_container running
|
|
|
|
|
|
|
|
start_container running
|
|
|
|
stop_container running
|
|
|
|
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX --verbose run --container running echo -n "Hello World"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-07-16 18:32:06 +00:00
|
|
|
assert_line --index $((${#lines[@]}-1)) "Hello World"
|
2020-07-27 13:35:17 +00:00
|
|
|
}
|
2020-08-10 17:07:17 +00:00
|
|
|
|
|
|
|
@test "run: Run sudo id inside of the default container" {
|
|
|
|
create_default_container
|
|
|
|
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX --verbose run sudo id
|
2020-08-10 17:07:17 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-07-16 18:32:06 +00:00
|
|
|
assert_line --index $((${#lines[@]}-1)) --partial "uid=0(root)"
|
2020-08-10 17:07:17 +00:00
|
|
|
}
|