Merge lp:~chipaca/snappy/no-empty-channel-in-update into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by John Lenton on 2015-10-26
Status: Merged
Approved by: John Lenton on 2015-10-26
Approved revision: 798
Merged at revision: 798
Proposed branch: lp:~chipaca/snappy/no-empty-channel-in-update
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 129 lines (+33/-10)
5 files modified
snappy/click_test.go (+2/-2)
snappy/common_test.go (+5/-5)
snappy/parts.go (+12/-0)
snappy/parts_test.go (+14/-0)
snappy/snapp.go (+0/-3)
To merge this branch: bzr merge lp:~chipaca/snappy/no-empty-channel-in-update
Reviewer Review Type Date Requested Status
Michael Vogt Approve on 2015-10-26
Sergio Schvezov 2015-10-26 Approve on 2015-10-26
Review via email: mp+275731@code.launchpad.net

Commit Message

Don't include empty channels in the bulk POST.

To post a comment you must log in.
Sergio Schvezov (sergiusens) wrote :

The code looks good, I just don't understand one thing

review: Needs Information
review: Approve
Michael Vogt (mvo) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy/click_test.go'
2--- snappy/click_test.go 2015-10-16 16:35:37 +0000
3+++ snappy/click_test.go 2015-10-26 16:00:20 +0000
4@@ -523,7 +523,7 @@
5 vendor: Foo Bar <foo@example.com>`)
6 _, err := installClick(snapFile, AllowOEM, nil, testOrigin)
7 c.Assert(err, IsNil)
8- c.Assert(storeMinimalRemoteManifest("foo", "foo", testOrigin, "1.0", ""), IsNil)
9+ c.Assert(storeMinimalRemoteManifest("foo", "foo", testOrigin, "1.0", "", "remote-channel"), IsNil)
10
11 contentFile := filepath.Join(s.tempdir, "oem", "foo", "1.0", "bin", "foo")
12 _, err = os.Stat(contentFile)
13@@ -539,7 +539,7 @@
14 vendor: Foo Bar <foo@example.com>`)
15 _, err = installClick(snapFile, 0, nil, testOrigin)
16 c.Check(err, IsNil)
17- c.Assert(storeMinimalRemoteManifest("foo", "foo", testOrigin, "2.0", ""), IsNil)
18+ c.Assert(storeMinimalRemoteManifest("foo", "foo", testOrigin, "2.0", "", "remote-channel"), IsNil)
19
20 // XXX: I think this next test now tests something we actually don't
21 // want. At least for fwks and apps, sideloading something installed
22
23=== modified file 'snappy/common_test.go'
24--- snappy/common_test.go 2015-10-15 08:26:11 +0000
25+++ snappy/common_test.go 2015-10-26 16:00:20 +0000
26@@ -92,14 +92,14 @@
27 return "", err
28 }
29
30- if err := storeMinimalRemoteManifest(dirName, m.Name, testOrigin, m.Version, "Hello"); err != nil {
31+ if err := storeMinimalRemoteManifest(dirName, m.Name, testOrigin, m.Version, "Hello", "remote-channel"); err != nil {
32 return "", err
33 }
34
35 return yamlFile, nil
36 }
37
38-func storeMinimalRemoteManifest(qn, name, origin, version, desc string) error {
39+func storeMinimalRemoteManifest(qn, name, origin, version, desc, channel string) error {
40 if origin == SideloadedOrigin {
41 panic("store remote manifest for sideloaded package")
42 }
43@@ -108,7 +108,7 @@
44 Origin: origin,
45 Version: version,
46 Description: desc,
47- Channel: "remote-channel",
48+ Channel: channel,
49 })
50 if err != nil {
51 return err
52@@ -205,13 +205,13 @@
53 n, err := installClick(snapFile, AllowUnauthenticated|AllowOEM, inter, testOrigin)
54 c.Assert(err, IsNil)
55 c.Assert(n, Equals, "foo")
56- c.Assert(storeMinimalRemoteManifest(qn, "foo", testOrigin, "1.0", ""), IsNil)
57+ c.Assert(storeMinimalRemoteManifest(qn, "foo", testOrigin, "1.0", "", "remote-channel"), IsNil)
58
59 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
60 n, err = installClick(snapFile, AllowUnauthenticated|AllowOEM, inter, testOrigin)
61 c.Assert(err, IsNil)
62 c.Assert(n, Equals, "foo")
63- c.Assert(storeMinimalRemoteManifest(qn, "foo", testOrigin, "2.0", ""), IsNil)
64+ c.Assert(storeMinimalRemoteManifest(qn, "foo", testOrigin, "2.0", "", "remote-channel"), IsNil)
65
66 m := NewMetaRepository()
67 installed, err := m.Installed()
68
69=== modified file 'snappy/parts.go'
70--- snappy/parts.go 2015-10-20 06:43:30 +0000
71+++ snappy/parts.go 2015-10-26 16:00:20 +0000
72@@ -64,6 +64,18 @@
73 return p.Name() + "." + p.Origin()
74 }
75
76+// FullNameWithChannel returns the FullName, with the channel appended
77+// if it has one.
78+func fullNameWithChannel(p Part) string {
79+ name := FullName(p)
80+ ch := p.Channel()
81+ if ch == "" {
82+ return name
83+ }
84+
85+ return fmt.Sprintf("%s/%s", name, ch)
86+}
87+
88 // Part representation of a snappy part
89 type Part interface {
90
91
92=== modified file 'snappy/parts_test.go'
93--- snappy/parts_test.go 2015-10-10 13:27:50 +0000
94+++ snappy/parts_test.go 2015-10-26 16:00:20 +0000
95@@ -85,6 +85,20 @@
96 {QualifiedName, pkg.TypeFramework, "fwk"},
97 {FullName, pkg.TypeApp, "app." + testOrigin},
98 {FullName, pkg.TypeFramework, "fwk." + testOrigin},
99+ {fullNameWithChannel, pkg.TypeApp, "app." + testOrigin + "/remote-channel"},
100+ {fullNameWithChannel, pkg.TypeFramework, "fwk." + testOrigin + "/remote-channel"},
101+ } {
102+ names, err := ActiveSnapIterByType(t.f, t.t)
103+ c.Check(err, IsNil)
104+ c.Check(names, DeepEquals, []string{t.n})
105+ }
106+
107+ // now remove the channel
108+ storeMinimalRemoteManifest("app."+testOrigin, "app", testOrigin, "1.10", "Hello.", "")
109+ storeMinimalRemoteManifest("fwk", "fwk", testOrigin, "1.0", "Hello.", "")
110+ for _, t := range []T{
111+ {fullNameWithChannel, pkg.TypeApp, "app." + testOrigin},
112+ {fullNameWithChannel, pkg.TypeFramework, "fwk." + testOrigin},
113 } {
114 names, err := ActiveSnapIterByType(t.f, t.t)
115 c.Check(err, IsNil)
116
117=== modified file 'snappy/snapp.go'
118--- snappy/snapp.go 2015-10-15 08:26:11 +0000
119+++ snappy/snapp.go 2015-10-26 16:00:20 +0000
120@@ -1908,9 +1908,6 @@
121 // sense in sending it our ubuntu-core snap
122 //
123 // NOTE this *will* send .sideload apps to the store.
124- fullNameWithChannel := func(p Part) string {
125- return fmt.Sprintf("%s/%s", FullName(p), p.Channel())
126- }
127 installed, err := ActiveSnapIterByType(fullNameWithChannel, pkg.TypeApp, pkg.TypeFramework, pkg.TypeOem)
128 if err != nil || len(installed) == 0 {
129 return nil, err

Subscribers

People subscribed via source and target branches