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() {
|
2021-11-11 00:46:21 +00:00
|
|
|
_setup_environment
|
2020-07-27 13:35:17 +00:00
|
|
|
cleanup_containers
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
cleanup_containers
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "create: Create the default container" {
|
|
|
|
pull_default_image
|
|
|
|
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX -y create
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "create: Create a container with a valid custom name ('custom-containerName')" {
|
2021-05-25 22:09:53 +00:00
|
|
|
pull_default_image
|
|
|
|
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX -y create -c "custom-containerName"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
2021-05-26 22:13:18 +00:00
|
|
|
@test "create: Create a container with a custom image and name ('fedora32'; f32)" {
|
2021-05-25 22:09:53 +00:00
|
|
|
pull_distro_image fedora 32
|
2020-07-27 13:35:17 +00:00
|
|
|
|
2021-05-26 22:13:18 +00:00
|
|
|
run $TOOLBOX -y create -c "fedora32" -i fedora-toolbox:32
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "create: Try to create a container with invalid custom name ('ßpeci@l.Nam€'; using positional argument)" {
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX -y create "ßpeci@l.Nam€"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
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)" {
|
2021-05-26 20:12:18 +00:00
|
|
|
run $TOOLBOX -y create -c "ßpeci@l.Nam€"
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
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."
|
|
|
|
}
|
2021-02-12 18:55:48 +00:00
|
|
|
|
2021-05-26 22:13:18 +00:00
|
|
|
@test "create: Create a container with a distro and release options ('fedora'; f32)" {
|
2021-05-25 22:09:53 +00:00
|
|
|
pull_distro_image fedora 32
|
2021-02-12 18:55:48 +00:00
|
|
|
|
2021-05-26 22:13:18 +00:00
|
|
|
run $TOOLBOX -y create -d "fedora" -r f32
|
2021-02-12 18:55:48 +00:00
|
|
|
|
|
|
|
assert_success
|
2021-05-26 22:13:18 +00:00
|
|
|
assert_output --partial "Created container: fedora-toolbox-32"
|
2021-07-22 23:22:50 +00:00
|
|
|
assert_output --partial "Enter with: toolbox enter fedora-toolbox-32"
|
2021-02-12 18:55:48 +00:00
|
|
|
|
|
|
|
# Make sure the container has actually been created
|
|
|
|
run podman ps -a
|
|
|
|
|
2021-05-26 22:13:18 +00:00
|
|
|
assert_output --regexp "Created[[:blank:]]+fedora-toolbox-32"
|
2021-02-12 18:55:48 +00:00
|
|
|
}
|
2021-07-28 13:57:45 +00:00
|
|
|
|
|
|
|
@test "create: Try to create a container based on non-existent image" {
|
|
|
|
run $TOOLBOX -y create -i foo.org/bar
|
|
|
|
|
|
|
|
assert_failure
|
|
|
|
assert_line --index 0 "Error: failed to pull image foo.org/bar"
|
|
|
|
assert_line --index 1 "If it was a private image, log in with: podman login foo.org"
|
|
|
|
assert_line --index 2 "Use 'toolbox --verbose ...' for further details."
|
|
|
|
}
|