Merge lp:~fgimenez/snappy/activate-test into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Federico Gimenez
Status: Merged
Approved by: Leo Arias
Approved revision: 750
Merged at revision: 754
Proposed branch: lp:~fgimenez/snappy/activate-test
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 120 lines (+96/-0)
4 files modified
_integration-tests/data/snaps/basic-binaries/bin/echo (+3/-0)
_integration-tests/data/snaps/basic-binaries/meta/package.yaml (+6/-0)
_integration-tests/data/snaps/basic-binaries/meta/readme.md (+3/-0)
_integration-tests/tests/activate_test.go (+84/-0)
To merge this branch: bzr merge lp:~fgimenez/snappy/activate-test
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Review via email: mp+273846@code.launchpad.net

Commit message

Activate test

Description of the change

Activate test

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

cool. Just please rename it to basic-binaries so I can add my failed bin.
Also take a look from my branch of the constants I moved to the data.go. If you like it you can do that here, or I'll update your const on my branch once yours lands.

Here's an idea: Lets make a snaps cache, so we have to build them only once. I'll make a card.

About:

+func (s *activateSuite) TestSnapIsInstalled(c *check.C) {

I'm not sure. Do we need it? common.InstallSnap(c, s.snapPath) would fail if something is wrong, and we already have a test to check that list shows the installed snaps.

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

> cool. Just please rename it to basic-binaries so I can add my failed bin.
> Also take a look from my branch of the constants I moved to the data.go. If
> you like it you can do that here, or I'll update your const on my branch once
> yours lands.

Ok, feel free to move it there.

>
> Here's an idea: Lets make a snaps cache, so we have to build them only once.
> I'll make a card.

Awesome! That will make test writing easier and execution quicker :)

>
> About:
>
> +func (s *activateSuite) TestSnapIsInstalled(c *check.C) {
>
> I'm not sure. Do we need it? common.InstallSnap(c, s.snapPath) would fail if
> something is wrong, and we already have a test to check that list shows the
> installed snaps.

The main point of this test was just to make sure that the snap is listed by snappy list -v with a trailing "*". Anyway, it feels like a "nothing in my pockets, nothing up my sleeves" thing :) i'll remove it.

Thanks!

lp:~fgimenez/snappy/activate-test updated
748. By Federico Gimenez

renamed snap; removed TestSnapIsInstalled

749. By Federico Gimenez

added new snap

750. By Federico Gimenez

fixed snap name

Revision history for this message
Leo Arias (elopio) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '_integration-tests/data/snaps/basic-binaries'
2=== added directory '_integration-tests/data/snaps/basic-binaries/bin'
3=== added file '_integration-tests/data/snaps/basic-binaries/bin/echo'
4--- _integration-tests/data/snaps/basic-binaries/bin/echo 1970-01-01 00:00:00 +0000
5+++ _integration-tests/data/snaps/basic-binaries/bin/echo 2015-10-09 07:49:28 +0000
6@@ -0,0 +1,3 @@
7+#!/bin/sh
8+
9+echo "From basic-binaries snap"
10
11=== added directory '_integration-tests/data/snaps/basic-binaries/meta'
12=== added file '_integration-tests/data/snaps/basic-binaries/meta/package.yaml'
13--- _integration-tests/data/snaps/basic-binaries/meta/package.yaml 1970-01-01 00:00:00 +0000
14+++ _integration-tests/data/snaps/basic-binaries/meta/package.yaml 2015-10-09 07:49:28 +0000
15@@ -0,0 +1,6 @@
16+name: basic-binaries
17+version: 1.0
18+vendor: Snappy Developers <snappy-devel@lists.ubuntu.com>
19+icon: meta/snappy64.png
20+binaries:
21+ - name: bin/echo
22
23=== added file '_integration-tests/data/snaps/basic-binaries/meta/readme.md'
24--- _integration-tests/data/snaps/basic-binaries/meta/readme.md 1970-01-01 00:00:00 +0000
25+++ _integration-tests/data/snaps/basic-binaries/meta/readme.md 2015-10-09 07:49:28 +0000
26@@ -0,0 +1,3 @@
27+Basic Binary snap
28+
29+A basic snap with binary entries
30
31=== added file '_integration-tests/data/snaps/basic-binaries/meta/snappy64.png'
32Binary files _integration-tests/data/snaps/basic-binaries/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/basic-binaries/meta/snappy64.png 2015-10-09 07:49:28 +0000 differ
33=== added file '_integration-tests/tests/activate_test.go'
34--- _integration-tests/tests/activate_test.go 1970-01-01 00:00:00 +0000
35+++ _integration-tests/tests/activate_test.go 2015-10-09 07:49:28 +0000
36@@ -0,0 +1,84 @@
37+// -*- Mode: Go; indent-tabs-mode: t -*-
38+
39+/*
40+ * Copyright (C) 2015 Canonical Ltd
41+ *
42+ * This program is free software: you can redistribute it and/or modify
43+ * it under the terms of the GNU General Public License version 3 as
44+ * published by the Free Software Foundation.
45+ *
46+ * This program is distributed in the hope that it will be useful,
47+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
48+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+ * GNU General Public License for more details.
50+ *
51+ * You should have received a copy of the GNU General Public License
52+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
53+ *
54+ */
55+
56+package tests
57+
58+import (
59+ "os"
60+
61+ "gopkg.in/check.v1"
62+
63+ "launchpad.net/snappy/_integration-tests/testutils/build"
64+ "launchpad.net/snappy/_integration-tests/testutils/cli"
65+ "launchpad.net/snappy/_integration-tests/testutils/common"
66+)
67+
68+const (
69+ activateSnapName = "basic-binaries"
70+ activateBinName = activateSnapName + ".echo"
71+ activateEchoOutput = "From basic-binaries snap\n"
72+ baseActivatePattern = "(?msU).*" + activateSnapName + `\s*.*\s*.*sideload`
73+ activatedPattern = baseActivatePattern + `\*\s*\n.*`
74+ deActivatedPattern = baseActivatePattern + `\s*\n.*`
75+)
76+
77+var _ = check.Suite(&activateSuite{})
78+
79+type activateSuite struct {
80+ common.SnappySuite
81+ snapPath string
82+}
83+
84+func (s *activateSuite) SetUpSuite(c *check.C) {
85+ s.SnappySuite.SetUpSuite(c)
86+ var err error
87+ s.snapPath, err = build.LocalSnap(c, activateSnapName)
88+ c.Assert(err, check.IsNil)
89+ common.InstallSnap(c, s.snapPath)
90+}
91+
92+func (s *activateSuite) TearDownSuite(c *check.C) {
93+ os.Remove(s.snapPath)
94+ common.RemoveSnap(c, activateSnapName)
95+}
96+
97+func (s *activateSuite) TestDeactivateRemovesBinary(c *check.C) {
98+ cli.ExecCommand(c, "sudo", "snappy", "deactivate", activateSnapName)
99+ defer cli.ExecCommand(c, "sudo", "snappy", "activate", activateSnapName)
100+ output, err := cli.ExecCommandErr(activateBinName)
101+
102+ c.Assert(err, check.NotNil)
103+ c.Assert(output, check.Not(check.Equals), activateEchoOutput)
104+
105+ list := cli.ExecCommand(c, "snappy", "list", "-v")
106+
107+ c.Assert(list, check.Matches, deActivatedPattern)
108+}
109+
110+func (s *activateSuite) TestActivateBringsBinaryBack(c *check.C) {
111+ cli.ExecCommand(c, "sudo", "snappy", "deactivate", activateSnapName)
112+ cli.ExecCommand(c, "sudo", "snappy", "activate", activateSnapName)
113+ output := cli.ExecCommand(c, activateBinName)
114+
115+ c.Assert(output, check.Equals, activateEchoOutput)
116+
117+ list := cli.ExecCommand(c, "snappy", "list", "-v")
118+
119+ c.Assert(list, check.Matches, activatedPattern)
120+}

Subscribers

People subscribed via source and target branches