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

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 766
Merged at revision: 773
Proposed branch: lp:~elopio/snappy/examples5
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~elopio/snappy/examples4
Diff against target: 56 lines (+41/-0)
1 file modified
_integration-tests/tests/examples_test.go (+41/-0)
To merge this branch: bzr merge lp:~elopio/snappy/examples5
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+274350@code.launchpad.net

Commit message

Added tests for the config example snaps.

To post a comment you must log in.
lp:~elopio/snappy/examples5 updated
766. By Leo Arias

Fixed fmt.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

Very nice! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '_integration-tests/tests/examples_test.go'
--- _integration-tests/tests/examples_test.go 2015-10-14 05:18:42 +0000
+++ _integration-tests/tests/examples_test.go 2015-10-14 05:18:43 +0000
@@ -20,7 +20,10 @@
20package tests20package tests
2121
22import (22import (
23 "fmt"
24 "io/ioutil"
23 "net/http"25 "net/http"
26 "os"
2427
25 "launchpad.net/snappy/_integration-tests/testutils/cli"28 "launchpad.net/snappy/_integration-tests/testutils/cli"
26 "launchpad.net/snappy/_integration-tests/testutils/common"29 "launchpad.net/snappy/_integration-tests/testutils/common"
@@ -107,3 +110,41 @@
107 c.Assert(output, check.Equals, expected,110 c.Assert(output, check.Equals, expected,
108 check.Commentf("Expected output %s not found, %s", expected, output))111 check.Commentf("Expected output %s not found, %s", expected, output))
109}112}
113
114var _ = check.Suite(&configExampleSuite{})
115
116type configExampleSuite struct {
117 common.SnappySuite
118}
119
120var configTests = []struct {
121 snap string
122 origin string
123 message string
124}{
125 {"config-example", "", "test config example message"},
126 {"config-example-bash", ".canonical", "test config example bash message"},
127}
128
129func (s *configExampleSuite) TestPrintMessageFromConfig(c *check.C) {
130 for _, t := range configTests {
131 common.InstallSnap(c, t.snap+t.origin)
132 defer common.RemoveSnap(c, t.snap)
133
134 config := fmt.Sprintf(`config:
135 %s:
136 msg: |
137 %s`, t.snap, t.message)
138
139 configFile, err := ioutil.TempFile("", "snappy-cfg")
140 defer func() { configFile.Close(); os.Remove(configFile.Name()) }()
141 c.Assert(err, check.IsNil, check.Commentf("Error creating temp file: %s", err))
142 _, err = configFile.Write([]byte(config))
143 c.Assert(err, check.IsNil, check.Commentf("Error writing the conf to the temp file: %s", err))
144
145 cli.ExecCommand(c, "sudo", "snappy", "config", t.snap, configFile.Name())
146
147 output := cli.ExecCommand(c, t.snap+".hello")
148 c.Assert(output, check.Equals, t.message, check.Commentf("Wrong message"))
149 }
150}

Subscribers

People subscribed via source and target branches