Skip to content

Commit

Permalink
test: add tests for --clear={cmd,entrypoint}
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksa Sarai <asarai@suse.de>
  • Loading branch information
cyphar committed Apr 5, 2017
1 parent 025556a commit 2a596ae
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion test/config.bats
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,48 @@ function teardown() {
image-verify "${IMAGE}"
}

@test "umoci config --clear=config.{entrypoint or cmd}" {
BUNDLE_A="$(setup_tmpdir)"
BUNDLE_B="$(setup_tmpdir)"

# Modify the entrypoint+cmd.
umoci config --image "${IMAGE}:${TAG}" --config.entrypoint "sh" --config.entrypoint "/here is some values/" --config.cmd "-c" --config.cmd "ls -la" --config.cmd="kek"
[ "$status" -eq 0 ]
image-verify "${IMAGE}"

# Clear the entrypoint.
umoci config --image "${IMAGE}:${TAG}" --tag="${TAG}-noentry" --clear=config.entrypoint
[ "$status" -eq 0 ]
image-verify "${IMAGE}"

# Unpack the image.
umoci unpack --image "${IMAGE}:${TAG}-noentry" "$BUNDLE_A"
[ "$status" -eq 0 ]
bundle-verify "$BUNDLE_A"

# Ensure that the final args is only cmd.
sane_run jq -SMr 'reduce .process.args[] as $arg (""; . + $arg + ";")' "$BUNDLE_A/config.json"
[ "$status" -eq 0 ]
[[ "$output" == "-c;ls -la;kek;" ]]

# Clear the cmd.
umoci config --image "${IMAGE}:${TAG}" --tag="${TAG}-nocmd" --clear=config.cmd
[ "$status" -eq 0 ]
image-verify "${IMAGE}"

# Unpack the image.
umoci unpack --image "${IMAGE}:${TAG}-nocmd" "$BUNDLE_B"
[ "$status" -eq 0 ]
bundle-verify "$BUNDLE_B"

# Ensure that the final args is only cmd.
sane_run jq -SMr 'reduce .process.args[] as $arg (""; . + $arg + ";")' "$BUNDLE_B/config.json"
[ "$status" -eq 0 ]
[[ "$output" == "sh;/here is some values/;" ]]

image-verify "${IMAGE}"
}

@test "umoci config --config.cmd" {
BUNDLE="$(setup_tmpdir)"

Expand All @@ -416,10 +458,38 @@ function teardown() {
image-verify "${IMAGE}"
}

@test "umoci config --clear=config.[entrypoint+cmd]" {
BUNDLE="$(setup_tmpdir)"

# Modify the entrypoint+cmd.
umoci config --image "${IMAGE}:${TAG}" --config.entrypoint "sh" --config.entrypoint "/here is some values/" --config.cmd "-c" --config.cmd "ls -la" --config.cmd="kek"
[ "$status" -eq 0 ]
image-verify "${IMAGE}"

# Clear the entrypoint and entrypoint.
umoci config --image "${IMAGE}:${TAG}" --tag="${TAG}-nocmdentry" --clear=config.entrypoint --clear=config.cmd
[ "$status" -eq 0 ]
image-verify "${IMAGE}"

# Unpack the image.
umoci unpack --image "${IMAGE}:${TAG}-nocmdentry" "$BUNDLE"
[ "$status" -eq 0 ]
bundle-verify "$BUNDLE"

# Ensure that the final args is empty.
sane_run jq -SMr 'reduce .process.args[] as $arg (""; . + $arg + ";")' "$BUNDLE/config.json"
[ "$status" -eq 0 ]
# TODO: This is almost certainly not going to be valid when config.json
# conversion is part of the spec.
[[ "$output" == "sh;" ]]

image-verify "${IMAGE}"
}

@test "umoci config --config.[entrypoint+cmd]" {
BUNDLE="$(setup_tmpdir)"

# Modify none of the configuration.
# Modify the entrypoint+cmd.
umoci config --image "${IMAGE}:${TAG}" --config.entrypoint "sh" --config.cmd "-c" --config.cmd "ls -la"
[ "$status" -eq 0 ]
image-verify "${IMAGE}"
Expand Down

0 comments on commit 2a596ae

Please sign in to comment.