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
1=== modified file '_integration-tests/tests/examples_test.go'
2--- _integration-tests/tests/examples_test.go 2015-10-14 05:18:42 +0000
3+++ _integration-tests/tests/examples_test.go 2015-10-14 05:18:43 +0000
4@@ -20,7 +20,10 @@
5 package tests
6
7 import (
8+ "fmt"
9+ "io/ioutil"
10 "net/http"
11+ "os"
12
13 "launchpad.net/snappy/_integration-tests/testutils/cli"
14 "launchpad.net/snappy/_integration-tests/testutils/common"
15@@ -107,3 +110,41 @@
16 c.Assert(output, check.Equals, expected,
17 check.Commentf("Expected output %s not found, %s", expected, output))
18 }
19+
20+var _ = check.Suite(&configExampleSuite{})
21+
22+type configExampleSuite struct {
23+ common.SnappySuite
24+}
25+
26+var configTests = []struct {
27+ snap string
28+ origin string
29+ message string
30+}{
31+ {"config-example", "", "test config example message"},
32+ {"config-example-bash", ".canonical", "test config example bash message"},
33+}
34+
35+func (s *configExampleSuite) TestPrintMessageFromConfig(c *check.C) {
36+ for _, t := range configTests {
37+ common.InstallSnap(c, t.snap+t.origin)
38+ defer common.RemoveSnap(c, t.snap)
39+
40+ config := fmt.Sprintf(`config:
41+ %s:
42+ msg: |
43+ %s`, t.snap, t.message)
44+
45+ configFile, err := ioutil.TempFile("", "snappy-cfg")
46+ defer func() { configFile.Close(); os.Remove(configFile.Name()) }()
47+ c.Assert(err, check.IsNil, check.Commentf("Error creating temp file: %s", err))
48+ _, err = configFile.Write([]byte(config))
49+ c.Assert(err, check.IsNil, check.Commentf("Error writing the conf to the temp file: %s", err))
50+
51+ cli.ExecCommand(c, "sudo", "snappy", "config", t.snap, configFile.Name())
52+
53+ output := cli.ExecCommand(c, t.snap+".hello")
54+ c.Assert(output, check.Equals, t.message, check.Commentf("Wrong message"))
55+ }
56+}

Subscribers

People subscribed via source and target branches