summaryrefslogtreecommitdiff
path: root/tests
diff options
authorKyle Fazzari <kyle@canonical.com>2016-09-15 13:13:57 -0700
committerKyle Fazzari <kyle@canonical.com>2016-09-16 07:02:07 -0700
commit0759d761fa2b31462f739f822c8fb7dd77b28a38 (patch)
tree7227177cd237874922b54f138b56b901b503f8d2 /tests
parent9b854697e2d2654d0241c8c89c8086abc866bd26 (diff)
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 <kyle@canonical.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/main/snapctl/task.yaml17
1 files changed, 11 insertions, 6 deletions
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