Merge lp:~elopio/snappy/test_go_version into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 587
Merged at revision: 588
Proposed branch: lp:~elopio/snappy/test_go_version
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 78 lines (+35/-12)
2 files modified
_integration-tests/tests/02_test_versions (+0/-7)
_integration-tests/tests/latest/list_test.go (+35/-5)
To merge this branch: bzr merge lp:~elopio/snappy/test_go_version
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+265076@code.launchpad.net

Commit message

Translated the version integration test to go.

Description of the change

This one is a little tricky. We can't pass the version from the host to the testbed, because we accept relative versions like -1 or nothing to mean latest. So we would have to query the system-image server for the latest image, and calculate the relative version. But then we would need to know the device, which can be a lot of things and we don't take as an argument. Much too work for not much value IMO, so I settled for checking the value from the config.

To post a comment you must log in.
Revision history for this message
Federico Gimenez (fgimenez) wrote :

Looks good, +1

Maybe a system-image client as you mention can become useful, we can get all the required data from snappy info, then it's just a matter of parsing a remote json.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '_integration-tests/tests/02_test_versions'
2--- _integration-tests/tests/02_test_versions 2015-06-15 15:36:29 +0000
3+++ _integration-tests/tests/02_test_versions 1970-01-01 00:00:00 +0000
4@@ -1,7 +0,0 @@
5-test() {
6- T="ubuntu-core.*201?"
7- test_regexp "$T" $SNAPPY list
8-
9- T="Name.*Date.*Version.*Developer"
10- test_regexp "$T" $SNAPPY list
11-}
12
13=== modified file '_integration-tests/tests/latest/list_test.go'
14--- _integration-tests/tests/latest/list_test.go 2015-07-15 06:07:06 +0000
15+++ _integration-tests/tests/latest/list_test.go 2015-07-17 00:33:41 +0000
16@@ -20,18 +20,48 @@
17 package latest
18
19 import (
20+ "fmt"
21+ "os"
22+
23 . "../common"
24
25- . "gopkg.in/check.v1"
26+ "github.com/mvo5/goconfigparser"
27+ check "gopkg.in/check.v1"
28 )
29
30-var _ = Suite(&listSuite{})
31+var _ = check.Suite(&listSuite{})
32
33 type listSuite struct {
34 SnappySuite
35 }
36
37-func (s *listSuite) TestListMustPrintAppVersion(c *C) {
38+func getVersionFromConfig(c *check.C) string {
39+ cfg := goconfigparser.New()
40+ f, err := os.Open("/etc/system-image/channel.ini")
41+ c.Assert(err, check.IsNil,
42+ check.Commentf("Error opening the config file: %v:", err))
43+ defer f.Close()
44+ err = cfg.Read(f)
45+ c.Assert(err, check.IsNil,
46+ check.Commentf("Error parsing the config file: %v", err))
47+ version, err := cfg.Get("service", "build_number")
48+ c.Assert(err, check.IsNil,
49+ check.Commentf("Error getting the build number: %v", err))
50+ return version
51+}
52+
53+func (s *listSuite) TestListMustPrintCoreVersion(c *check.C) {
54+ listOutput := ExecCommand(c, "snappy", "list")
55+
56+ expected := "(?ms)" +
57+ "Name +Date +Version +Developer *\n" +
58+ ".*" +
59+ fmt.Sprintf("^ubuntu-core +.* +%s +ubuntu *\n", getVersionFromConfig(c)) +
60+ ".*"
61+ c.Assert(listOutput, check.Matches, expected)
62+}
63+
64+func (s *listSuite) TestListMustPrintAppVersion(c *check.C) {
65 InstallSnap(c, "hello-world")
66 s.AddCleanup(func() {
67 RemoveSnap(c, "hello-world")
68@@ -41,8 +71,8 @@
69 expected := "(?ms)" +
70 "Name +Date +Version +Developer *\n" +
71 ".*" +
72- "^hello-world +.* (\\d+)(\\.\\d+)* +.* +.* *\n" +
73+ "^hello-world +.* +(\\d+)(\\.\\d+)* +.* +.* *\n" +
74 ".*"
75
76- c.Assert(listOutput, Matches, expected)
77+ c.Assert(listOutput, check.Matches, expected)
78 }

Subscribers

People subscribed via source and target branches