Merge lp:~jonas-drange/ubuntu-push/lp1554547 into lp:ubuntu-push

Proposed by Jonas G. Drange
Status: Superseded
Proposed branch: lp:~jonas-drange/ubuntu-push/lp1554547
Merge into: lp:ubuntu-push
Diff against target: 133 lines (+58/-15)
3 files modified
bus/systemimage/systemimage.go (+33/-6)
bus/systemimage/systemimage_test.go (+24/-8)
client/client.go (+1/-1)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-push/lp1554547
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers Pending
Review via email: mp+288425@code.launchpad.net

Commit message

deprecate the usage of Info and replace it with Information

To post a comment you must log in.
160. By Jonas G. Drange

fix test failure in client caused by Info -> Information

Unmerged revisions

160. By Jonas G. Drange

fix test failure in client caused by Info -> Information

159. By Jonas G. Drange

deprecate the Info usage

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bus/systemimage/systemimage.go'
2--- bus/systemimage/systemimage.go 2015-01-21 17:21:42 +0000
3+++ bus/systemimage/systemimage.go 2016-03-08 17:27:16 +0000
4@@ -18,6 +18,9 @@
5 package systemimage
6
7 import (
8+ "strconv"
9+ "strings"
10+
11 "launchpad.net/ubuntu-push/bus"
12 "launchpad.net/ubuntu-push/logger"
13 )
14@@ -37,11 +40,12 @@
15 // xxx channel_target missing
16 LastUpdate string
17 VersionDetail map[string]string
18+ Raw map[string]string
19 }
20
21 // A SystemImage exposes the a subset of system-image service.
22 type SystemImage interface {
23- Info() (*InfoResult, error)
24+ Information() (*InfoResult, error)
25 }
26
27 type systemImage struct {
28@@ -56,13 +60,36 @@
29
30 var _ SystemImage = &systemImage{} // ensures it conforms
31
32-func (si *systemImage) Info() (*InfoResult, error) {
33- si.log.Debugf("invoking Info")
34- res := &InfoResult{}
35- err := si.endp.Call("Info", bus.Args(), &res.BuildNumber, &res.Device, &res.Channel, &res.LastUpdate, &res.VersionDetail)
36+func (si *systemImage) Information() (*InfoResult, error) {
37+ m := map[string]string{}
38+ err := si.endp.Call("Information", bus.Args(), &m)
39+
40 if err != nil {
41- si.log.Errorf("Info failed: %v", err)
42+ si.log.Errorf("Information failed: %v", err)
43 return nil, err
44 }
45+
46+ res := &InfoResult{}
47+
48+ bn, err := strconv.ParseInt(m["current_build_number"], 10, 32)
49+ if err == nil {
50+ res.BuildNumber = int32(bn)
51+ } else {
52+ res.BuildNumber = -1
53+ }
54+
55+ res.Device = m["device_name"]
56+ res.Channel = m["channel_name"]
57+ res.LastUpdate = m["last_update_date"]
58+ res.VersionDetail = map[string]string{}
59+
60+ // Split version detail key=value,key2=value2 into a string map
61+ vals := strings.Split(m["version_detail"], ",")
62+ for _, val := range vals {
63+ pairs := strings.Split(val, "=")
64+ res.VersionDetail[pairs[0]] = pairs[1]
65+ }
66+ res.Raw = m
67+
68 return res, err
69 }
70
71=== modified file 'bus/systemimage/systemimage_test.go'
72--- bus/systemimage/systemimage_test.go 2014-04-02 08:46:48 +0000
73+++ bus/systemimage/systemimage_test.go 2016-03-08 17:27:16 +0000
74@@ -41,22 +41,38 @@
75 }
76
77 func (s *SISuite) TestWorks(c *C) {
78- endp := testibus.NewMultiValuedTestingEndpoint(nil, condition.Work(true), []interface{}{int32(101), "mako", "daily", "Unknown", map[string]string{}})
79+ m := map[string]string{
80+ "version_detail": "ubuntu=20160304.2,device=20160304.2,custom=20160304.2,version=381",
81+ "last_update_date": "2016-03-04 15:25:31",
82+ "last_check_date": "2016-03-08 04:30:34",
83+ "target_version_detail": "-1",
84+ "device_name": "mako",
85+ "target_build_number": "-1",
86+ "channel_name": "ubuntu-touch/rc-proposed/ubuntu",
87+ "current_build_number": "381",
88+ }
89+ endp := testibus.NewMultiValuedTestingEndpoint(nil, condition.Work(true), []interface{}{m})
90 si := New(endp, s.log)
91- res, err := si.Info()
92+ res, err := si.Information()
93 c.Assert(err, IsNil)
94 c.Check(res, DeepEquals, &InfoResult{
95- BuildNumber: 101,
96- Device: "mako",
97- Channel: "daily",
98- LastUpdate: "Unknown",
99- VersionDetail: map[string]string{},
100+ BuildNumber: 381,
101+ Device: "mako",
102+ Channel: "ubuntu-touch/rc-proposed/ubuntu",
103+ LastUpdate: "2016-03-04 15:25:31",
104+ VersionDetail: map[string]string{
105+ "ubuntu": "20160304.2",
106+ "device": "20160304.2",
107+ "custom": "20160304.2",
108+ "version": "381",
109+ },
110+ Raw: m,
111 })
112 }
113
114 func (s *SISuite) TestFailsIfCallFails(c *C) {
115 endp := testibus.NewTestingEndpoint(nil, condition.Work(false))
116 si := New(endp, s.log)
117- _, err := si.Info()
118+ _, err := si.Information()
119 c.Check(err, NotNil)
120 }
121
122=== modified file 'client/client.go'
123--- client/client.go 2015-09-30 14:44:14 +0000
124+++ client/client.go 2016-03-08 17:27:16 +0000
125@@ -292,7 +292,7 @@
126 go cs.Track(client.connCh)
127 util.NewAutoRedialer(client.systemImageEndp).Redial()
128 sysimg := systemimage.New(client.systemImageEndp, client.log)
129- info, err := sysimg.Info()
130+ info, err := sysimg.Information()
131 if err != nil {
132 return err
133 }

Subscribers

People subscribed via source and target branches