toolbox/test/system/101-create.bats
Ondřej Míchal 871d905ceb test/system: Use env var for invoking Toolbox
The system test refactor[0] replaced the 'run_toolbox' helper function
with 'run toolbox', which is a normal invocation of Toolbox. This makes
it impossible to override Toolbox used during the tests using env var.

[0] https://github.com/containers/toolbox/pull/693
2021-05-26 22:52:40 +02:00

69 lines
1.8 KiB
Bash

#!/usr/bin/env bats
load 'libs/bats-support/load'
load 'libs/bats-assert/load'
load 'libs/helpers'
setup() {
cleanup_containers
}
teardown() {
cleanup_containers
}
@test "create: Create the default container" {
pull_default_image
run $TOOLBOX -y create
assert_success
}
@test "create: Create a container with a valid custom name ('custom-containerName')" {
run $TOOLBOX -y create -c "custom-containerName"
assert_success
}
@test "create: Create a container with a custom image and name ('fedora29'; f29)" {
pull_image_old 29
run $TOOLBOX -y create -c "fedora29" -i fedora-toolbox:29
assert_success
}
@test "create: Try to create a container with invalid custom name ('ßpeci@l.Nam€'; using positional argument)" {
run $TOOLBOX -y create "ßpeci@l.Nam€"
assert_failure
assert_line --index 0 "Error: invalid argument for 'CONTAINER'"
assert_line --index 1 "Container names must match '[a-zA-Z0-9][a-zA-Z0-9_.-]*'"
assert_line --index 2 "Run 'toolbox --help' for usage."
}
@test "create: Try to create a container with invalid custom name ('ßpeci@l.Nam€'; using option --container)" {
run $TOOLBOX -y create -c "ßpeci@l.Nam€"
assert_failure
assert_line --index 0 "Error: invalid argument for '--container'"
assert_line --index 1 "Container names must match '[a-zA-Z0-9][a-zA-Z0-9_.-]*'"
assert_line --index 2 "Run 'toolbox --help' for usage."
}
@test "create: Create a container with a distro and release options ('fedora'; f29)" {
pull_image 29
run $TOOLBOX -y create -d "fedora" -r f29
assert_success
assert_output --partial "Created container: fedora-toolbox-29"
assert_output --partial "Enter with: toolbox enter --release 29"
# Make sure the container has actually been created
run podman ps -a
assert_output --regexp "Created[[:blank:]]+fedora-toolbox-29"
}