Merge lp:~elopio/snappy/go-tests3 into lp:~fgimenez/snappy/go-functional-tests

Proposed by Leo Arias
Status: Merged
Approved by: Federico Gimenez
Approved revision: 511
Merged at revision: 496
Proposed branch: lp:~elopio/snappy/go-tests3
Merge into: lp:~fgimenez/snappy/go-functional-tests
Diff against target: 121 lines (+48/-20)
6 files modified
_integration-tests/snappy-selftest (+1/-0)
_integration-tests/tests/04_test_install_hello (+0/-7)
_integration-tests/tests/10_test_info_has_stuff (+0/-1)
_integration-tests/tests/snappy_test.go (+45/-10)
debian/integration-tests/control (+1/-1)
run-checks (+1/-1)
To merge this branch: bzr merge lp:~elopio/snappy/go-tests3
Reviewer Review Type Date Requested Status
Federico Gimenez Approve
Review via email: mp+262044@code.launchpad.net

Commit message

Final cleanup of the hello world tests.

To post a comment you must log in.
lp:~elopio/snappy/go-tests3 updated
502. By Leo Arias

Update the run checks.

503. By Leo Arias

Added the info test.

504. By Leo Arias

Removed the unnecessary comments.

505. By Leo Arias

Install snap.

506. By Leo Arias

Added the missing return.

507. By Leo Arias

Added the missing type.

508. By Leo Arias

Missing argument.

509. By Leo Arias

Match only one app installed.

510. By Leo Arias

disable autopilot.

511. By Leo Arias

Use the multiline flag.

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

Great Leo, thanks! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_integration-tests/snappy-selftest'
2--- _integration-tests/snappy-selftest 2015-06-15 15:36:29 +0000
3+++ _integration-tests/snappy-selftest 2015-06-16 06:55:19 +0000
4@@ -21,6 +21,7 @@
5
6 # prepare the environment
7 if [ -z "$ADT_REBOOT_MARK" ]; then
8+ sudo systemctl stop snappy-autopilot.timer
9 sudo snappy remove "$framework" 2>&1 || true
10 sudo snappy remove hello-world 2>&1 || true
11 sudo snappy remove xkcd-webserver 2>&1 || true
12
13=== removed file '_integration-tests/tests/04_test_install_hello'
14--- _integration-tests/tests/04_test_install_hello 2015-06-15 15:36:29 +0000
15+++ _integration-tests/tests/04_test_install_hello 1970-01-01 00:00:00 +0000
16@@ -1,7 +0,0 @@
17-test() {
18- T="hello-world[[:space:]]+[0-9]{4}-[0-9]{2}-[0-9]{2}[[:space:]]+[0-9]+(\.[0-9]+)+[[:space:]]+canonical"
19- test_regexp "$T" sudo $SNAPPY install hello-world
20-
21- T="Hello World!"
22- test_equal "$T" hello-world.echo
23-}
24
25=== modified file '_integration-tests/tests/10_test_info_has_stuff'
26--- _integration-tests/tests/10_test_info_has_stuff 2015-06-15 15:36:29 +0000
27+++ _integration-tests/tests/10_test_info_has_stuff 2015-06-16 06:55:19 +0000
28@@ -1,5 +1,4 @@
29 test() {
30 test_regexp "^release: ubuntu-core/.*/(edge|stable)" $SNAPPY info
31 test_regexp "^frameworks: $framework" $SNAPPY info
32- test_regexp "^apps:.*\<hello-world\>" $SNAPPY info
33 }
34
35=== modified file '_integration-tests/tests/snappy_test.go'
36--- _integration-tests/tests/snappy_test.go 2015-06-15 15:36:29 +0000
37+++ _integration-tests/tests/snappy_test.go 2015-06-16 06:55:19 +0000
38@@ -14,15 +14,50 @@
39
40 type InstallSuite struct{}
41
42-func (s *InstallSuite) TestInstallSnapp(c *C) {
43- installCommand := exec.Command("sudo", "snappy", "install", "hello-world")
44- _, installErr := installCommand.CombinedOutput()
45-
46- c.Assert(installErr, IsNil)
47-
48- echoCommand := exec.Command("hello-world.echo")
49- echoOutput, echoErr := echoCommand.CombinedOutput()
50-
51- c.Assert(echoErr, IsNil)
52+func (s *InstallSuite) installSnap(c *C, packageName string) []byte {
53+ return s.execCommand(c, "sudo", "snappy", "install", packageName)
54+}
55+
56+func (s *InstallSuite) execCommand(c *C, cmds ...string) []byte {
57+ cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...)
58+ output, err := cmd.CombinedOutput()
59+ c.Assert(err, IsNil, Commentf("Error: %v", output))
60+ return output
61+}
62+
63+func (s *InstallSuite) SetUpSuite(c *C) {
64+ s.execCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer")
65+}
66+
67+func (s *InstallSuite) TearDownTest(c *C) {
68+ s.execCommand(c, "sudo", "snappy", "remove", "hello-world")
69+}
70+
71+func (s *InstallSuite) TestInstallSnapMustPrintPackageInformation(c *C) {
72+ installOutput := s.installSnap(c, "hello-world")
73+
74+ expected := "" +
75+ "Installing hello-world\n" +
76+ "Name Date Version Developer \n" +
77+ ".*\n" +
78+ "hello-world .* .* canonical \n" +
79+ ".*\n"
80+ c.Assert(string(installOutput), Matches, expected)
81+}
82+
83+func (s *InstallSuite) TestCallBinaryFromInstalledSnap(c *C) {
84+ s.installSnap(c, "hello-world")
85+
86+ echoOutput := s.execCommand(c, "hello-world.echo")
87+
88 c.Assert(string(echoOutput), Equals, "Hello World!\n")
89 }
90+
91+func (s *InstallSuite) TestInfoMustPrintInstalledPackageInformation(c *C) {
92+ s.installSnap(c, "hello-world")
93+
94+ infoOutput := s.execCommand(c, "sudo", "snappy", "info")
95+
96+ expected := "(?m)^apps: hello-world\n"
97+ c.Assert(string(infoOutput), Matches, expected)
98+}
99
100=== modified file 'debian/integration-tests/control'
101--- debian/integration-tests/control 2015-06-15 15:36:29 +0000
102+++ debian/integration-tests/control 2015-06-16 06:55:19 +0000
103@@ -1,4 +1,4 @@
104-Test-Command: snappy.test
105+Test-Command: snappy.test -gocheck.vv -test.outputdir=$ADT_ARTIFACTS
106 Restrictions: allow-stderr
107 Depends: ubuntu-snappy-tests
108
109
110=== modified file 'run-checks'
111--- run-checks 2015-06-09 15:35:35 +0000
112+++ run-checks 2015-06-16 06:55:19 +0000
113@@ -58,7 +58,7 @@
114 # integration tests
115 if which adt-run >/dev/null 2>&1; then
116 echo "Running integration tests"
117- ./integration-tests/selftest
118+ go run _integration-tests/main.go
119 fi
120
121 echo "All good, what could possibly go wrong"

Subscribers

People subscribed via source and target branches

to all changes: