File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (105 lines) | stat: -rw-r--r-- 3,076 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
summary: Check that revert works.

details: |
    Check that when a snap is refreshed it can be reverted to the previous
    version. Verify that the data directories are present and the snap
    runs confined. Also check that a revert on an already reverted snap
    fails

# ubuntu-14.04: systemd-run not supported
systems: [-ubuntu-14.04*]

environment:
    STORE_TYPE/fake: fake
    STORE_TYPE/remote: ${REMOTE_STORE}
    BLOB_DIR: $(pwd)/fake-store-blobdir

prepare: |
    if [ "$STORE_TYPE" = "fake" ]; then
        if os.query is-core; then
            exit
        fi
        if [ "$TRUST_TEST_KEYS" = "false" ]; then
            echo "This test needs test keys to be trusted"
            exit
        fi
    fi

    echo "Given a snap is installed"
    snap install test-snapd-tools

    if [ "$STORE_TYPE" = "fake" ]; then
        "$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"

        echo "And a new version of that snap put in the controlled store"
        "$TESTSTOOLS"/store-state init-fake-refreshes "$BLOB_DIR" test-snapd-tools
    fi

restore: |
    if [ "$STORE_TYPE" = "fake" ]; then
        if os.query is-core; then
            exit
        fi
        if [ "$TRUST_TEST_KEYS" = "false" ]; then
            echo "This test needs test keys to be trusted"
            exit
        fi
        "$TESTSTOOLS"/store-state teardown-fake-store "$BLOB_DIR"
    fi

execute: |
    if [ "$STORE_TYPE" = "fake" ]; then
        if os.query is-core; then
            exit
        fi
        if [ "$TRUST_TEST_KEYS" = "false" ]; then
            echo "This test needs test keys to be trusted"
            exit
        fi
    fi

    echo "Revert without snap name shows error"
    if snap revert; then
        echo "Reverting without snap name should fail"
        exit 1
    fi

    echo "When a refresh is made"
    snap refresh --edge test-snapd-tools

    echo "Then the new version is installed"
    snap list | MATCH --  'test-snapd-tools +[0-9]+\.[0-9]+\+fake1'

    echo "And the snap runs"
    test-snapd-tools.echo hello|MATCH hello

    echo "When a revert is made"
    snap revert test-snapd-tools

    echo "Then the old version is active"
    snap list | MATCH -- 'test-snapd-tools +[0-9]+\.[0-9]+ '

    echo "And the data directories are present"
    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    find "$SNAP_MOUNT_DIR/test-snapd-tools" -maxdepth 1 | MATCH current
    find /var/snap/test-snapd-tools -maxdepth 1 | MATCH current

    echo "And the snap runs confined"
    snap list|MATCH 'test-snapd-tools.* -$'

    echo "And the still snap runs"
    test-snapd-tools.echo hello|MATCH hello

    echo "And a new revert fails"
    if snap revert test-snapd-tools; then
        echo "A revert on an already reverted snap should fail"
        exit 1
    fi

    echo "And a refresh doesn't update the snap"
    snap refresh
    snap list | MATCH -- 'test-snapd-tools +[0-9]+\.[0-9]+ '

    echo "Unless the snap is asked for explicitly"
    snap refresh --edge test-snapd-tools
    snap list | MATCH -- 'test-snapd-tools +[0-9]+\.[0-9]+\+fake1'