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 (92 lines) | stat: -rw-r--r-- 3,497 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
summary: Check snap search

details: |
    Check that `snap find` lists snaps that match the search terms, if any are
    provided. Check that results can be obtained from partial matches and even
    from a specific section, if --section is used. Check that `snap find` lists
    featured snaps if no search terms are provided. Check that the results
    include snaps in the beta and edge channels.

# autopkgtest run only a subset of tests that deals with the integration
# with the distro
backends: [-autopkgtest]

# s390x,ppc64el have nothing featured
systems: [-ubuntu-*-ppc64el, -ubuntu-*-s390x]

execute: |
    tests.exec is-skipped && exit 0

    echo "List all featured snaps"
    expected='(?s).*Name +Version +Publisher +Notes +Summary *\n(.*?\n)?.*'
    snap find > featured.txt
    if ! grep -Pzq "$expected" < featured.txt; then
        echo "expected out put $expected not found in:"
        cat featured.txt
        exit 1
    fi
    MATCH "No search term specified. Here are some interesting snaps" < featured.txt
    MATCH "Provide a search term for more specific results." < featured.txt

    if [ "$(wc -l < featured.txt)" -gt 50 ]; then
        echo "Found more than 50 featured apps, this seems bogus:"
        snap find
        exit 1
    fi
    if [ "$(wc -l < featured.txt)" -lt 2 ]; then
        echo "Not found any featured app, this seems bogus:"
        snap find
        exit 1
    fi

    echo "Exact matches"
    for snapName in test-snapd-tools test-snapd-python-webserver
    do
        expected="(?s)Name +Version +Publisher +Notes +Summary *\\n(.*?\\n)?${snapName} +.*? *\\n.*"
        snap find $snapName | grep -Pzq "$expected"
    done

    echo "Partial terms work too"
    expected='(?s)Name +Version +Publisher +Notes +Summary *\n(.*?\n)?test-snapd-tools +.*? *\n.*'
    snap find test-snapd- | grep -Pzq "$expected"

    echo "And a very specific query works too"
    # and returns a single result
    snap find python based example webserver test-snapd | tail -n -1 > aggregate.out
    test "$(wc -l < aggregate.out)" = "1"
    MATCH '^test-snapd-python-webserver +.*$' < aggregate.out

    echo "List of snaps in a section works"
    # NOTE: this shows featured snaps which change all the time, do not
    # make any assumptions about the contents
    test "$(snap find --section=featured | wc -l)" -gt 1

    # TODO: discuss with the store how we can make this test stable, i.e.
    #       that section/snap changes do not break us
    if os.query is-pc-amd64; then
        set +e
        snap find --section=photo-and-video vlc >vlc.log 2>&1
        retval=$?
        set -e

        if [ "$retval" -eq 0 ]; then
          MATCH vlc < vlc.log
        else
          MATCH 'error: cannot get snap sections: cannot retrieve sections: got unexpected HTTP status code 403 via GET to "https://api.snapcraft.io/api/v1/snaps/sections"' < vlc.log
        fi
    else
        # actual output:
        # Name           Version  Publisher  Notes  Summary
        # mjpg-streamer  2.0      ogra       -      UVC webcam streaming tool
        snap find --section=photo-and-video vlc 2>&1 | NOMATCH vlc
    fi

    # LP: 1740605
    if snap find " " | grep "status code 403"; then
        echo 'snap find " " returns non user friendly error with whitespace query'
        exit 1
    fi

    echo "List of snaps in edge and beta channels"
    snap find test-snapd-just- | MATCH "test-snapd-just-edge"
    snap find test-snapd-just- | MATCH "test-snapd-just-beta"