Skip to content

Commit c3f3006

Browse files
committed
t/main/snap-tasks: create spread test to ensure --format json produces valid JSON
1 parent 3d0df55 commit c3f3006

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/main/snap-tasks/tasks.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
summary: Check that `snap tasks` works as expected.
2+
3+
details: |
4+
Verifies that the command `snap tasks` properly lists the tasks
5+
associated with a change. Also check the error scenarios.
6+
7+
systems: [ubuntu-16.04-64, ubuntu-18.04-64, ubuntu-2*, ubuntu-core-*, fedora-*]
8+
9+
prepare: |
10+
# Install local test snap
11+
"$TESTSTOOLS"/install-local test-snap-with-components
12+
13+
restore: |
14+
snap remove --purge test-snap-tasks || true
15+
16+
execute: |
17+
echo "Install component to trigger a change"
18+
snap install test-snap-with-components+comp1
19+
20+
echo "Get the change ID for the install operation"
21+
CHANGE_ID_1=$(snap changes | grep "Install snap \"test-snap-with-components\"" | awk '{print $1}')
22+
23+
# Check that valid JSON output is produced for the change, and that it contains the expected task with the expected state.
24+
echo "Check that 'snap tasks' lists the task for the change (and accepts the --format option)"
25+
snap tasks --format json "$CHANGE_ID_1" | jq -e '.[0].id == "remove+comp1" and .[0].state == "done"' > /dev/null
26+

0 commit comments

Comments
 (0)