From 0759d761fa2b31462f739f822c8fb7dd77b28a38 Mon Sep 17 00:00:00 2001 From: Kyle Fazzari Date: Thu, 15 Sep 2016 13:13:57 -0700 Subject: many: support snapctl -h This makes the tool much easier to discover (and document). It requires that the API accepts a missing context, however, which means the commands need to verify its presence before using it. Signed-off-by: Kyle Fazzari --- tests/main/snapctl/task.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/main/snapctl/task.yaml b/tests/main/snapctl/task.yaml index 8d3f6267a6..73f26ef730 100644 --- a/tests/main/snapctl/task.yaml +++ b/tests/main/snapctl/task.yaml @@ -52,19 +52,24 @@ restore: | systemctl start snapd.service execute: | + echo "Verify that snapctl -h runs without a context" + + if ! snapctl -h; then + echo "Expected snapctl -h to be successful" + fi + echo "Run the hook that calls snapctl" - # This context is enough to hit the API, but the hook will fail since this - # context is obviously invalid. That failure still means we're correctly - # hitting the API, though, which is all we care about here. - export SNAP_CONTEXT="foo" + # The snapctl usage in the hook is invalid and will cause a failure. That + # failure still means we're correctly hitting the API, though, which is all + # we care about here. if output="$(snap run --hook=apply-config snapctl-hooks 2>&1 >/dev/null)"; then echo "Expected the hook to fail" exit 1 fi - if [[ ! "$output" =~ .*"no context for ID: \"foo\"".* ]]; then - echo "Expected failure to be due to missing context, but it was \"$output\"" + if [[ ! "$output" =~ .*"unknown flag".*bar.* ]]; then + echo "Expected failure to be due to unknown flag, but it was \"$output\"" exit 1 fi -- cgit v1.2.3