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
=== removed file '_integration-tests/tests/02_test_versions'
--- _integration-tests/tests/02_test_versions 2015-06-15 15:36:29 +0000
+++ _integration-tests/tests/02_test_versions 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1test() {
2 T="ubuntu-core.*201?"
3 test_regexp "$T" $SNAPPY list
4
5 T="Name.*Date.*Version.*Developer"
6 test_regexp "$T" $SNAPPY list
7}
80
=== modified file '_integration-tests/tests/latest/list_test.go'
--- _integration-tests/tests/latest/list_test.go 2015-07-15 06:07:06 +0000
+++ _integration-tests/tests/latest/list_test.go 2015-07-17 00:33:41 +0000
@@ -20,18 +20,48 @@
20package latest20package latest
2121
22import (22import (
23 "fmt"
24 "os"
25
23 . "../common"26 . "../common"
2427
25 . "gopkg.in/check.v1"28 "github.com/mvo5/goconfigparser"
29 check "gopkg.in/check.v1"
26)30)
2731
28var _ = Suite(&listSuite{})32var _ = check.Suite(&listSuite{})
2933
30type listSuite struct {34type listSuite struct {
31 SnappySuite35 SnappySuite
32}36}
3337
34func (s *listSuite) TestListMustPrintAppVersion(c *C) {38func 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
53func (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
64func (s *listSuite) TestListMustPrintAppVersion(c *check.C) {
35 InstallSnap(c, "hello-world")65 InstallSnap(c, "hello-world")
36 s.AddCleanup(func() {66 s.AddCleanup(func() {
37 RemoveSnap(c, "hello-world")67 RemoveSnap(c, "hello-world")
@@ -41,8 +71,8 @@
41 expected := "(?ms)" +71 expected := "(?ms)" +
42 "Name +Date +Version +Developer *\n" +72 "Name +Date +Version +Developer *\n" +
43 ".*" +73 ".*" +
44 "^hello-world +.* (\\d+)(\\.\\d+)* +.* +.* *\n" +74 "^hello-world +.* +(\\d+)(\\.\\d+)* +.* +.* *\n" +
45 ".*"75 ".*"
4676
47 c.Assert(listOutput, Matches, expected)77 c.Assert(listOutput, check.Matches, expected)
48}78}

Subscribers

People subscribed via source and target branches