Merge lp:~nikwen/ubuntu-push/old-cleanup-fix-revert into lp:ubuntu-push/automatic

Proposed by Niklas Wenzel
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 407
Merged at revision: 407
Proposed branch: lp:~nikwen/ubuntu-push/old-cleanup-fix-revert
Merge into: lp:ubuntu-push/automatic
Diff against target: 113 lines (+5/-48)
2 files modified
messaging/messaging.go (+3/-8)
messaging/messaging_test.go (+2/-40)
To merge this branch: bzr merge lp:~nikwen/ubuntu-push/old-cleanup-fix-revert
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+264918@code.launchpad.net

Commit message

Revert the old fix for LP: #1451510 as we have a new fix for it

Description of the change

Revert the old fix for LP: #1451510 as we have a new fix for it

To post a comment you must log in.
Revision history for this message
Samuele Pedroni (pedronis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'messaging/messaging.go'
2--- messaging/messaging.go 2015-05-20 07:31:17 +0000
3+++ messaging/messaging.go 2015-07-15 20:29:01 +0000
4@@ -81,10 +81,6 @@
5 func (mmu *MessagingMenu) cleanUpNotifications() {
6 mmu.lock.Lock()
7 defer mmu.lock.Unlock()
8- mmu.doCleanUpNotifications()
9-}
10-
11-func (mmu *MessagingMenu) doCleanUpNotifications() {
12 for nid, payload := range mmu.notifications {
13 if payload.Gone {
14 // sweep
15@@ -126,11 +122,10 @@
16 func (mmu *MessagingMenu) Tags(app *click.AppId) []string {
17 orig := app.Original()
18 tags := []string(nil)
19- mmu.lock.Lock()
20- defer mmu.lock.Unlock()
21- mmu.doCleanUpNotifications()
22+ mmu.lock.RLock()
23+ defer mmu.lock.RUnlock()
24 for _, payload := range mmu.notifications {
25- if payload.App.Original() == orig && !payload.Gone {
26+ if payload.App.Original() == orig {
27 tags = append(tags, payload.Tag)
28 }
29 }
30
31=== modified file 'messaging/messaging_test.go'
32--- messaging/messaging_test.go 2015-05-20 07:47:50 +0000
33+++ messaging/messaging_test.go 2015-07-15 20:29:01 +0000
34@@ -48,6 +48,8 @@
35 cRemoveNotification = func(a, n string) {
36 ms.log.Debugf("REMOVE: app: %s, not: %s", a, n)
37 }
38+ // just in case
39+ cNotificationExists = nil
40 }
41
42 func (ms *MessagingSuite) TearDownSuite(c *C) {
43@@ -59,8 +61,6 @@
44 func (ms *MessagingSuite) SetUpTest(c *C) {
45 ms.log = helpers.NewTestLogger(c, "debug")
46 ms.app = clickhelp.MustParseAppId("com.example.test_test_0")
47- // just in case
48- cNotificationExists = nil
49 }
50
51 func (ms *MessagingSuite) TestPresentPresents(c *C) {
52@@ -129,13 +129,6 @@
53 }
54
55 func (ms *MessagingSuite) TestTagsListsTags(c *C) {
56- existsCount := 0
57- // patch cnotificationexists to return true
58- cNotificationExists = func(did string, nid string) bool {
59- existsCount++
60- return true
61- }
62-
63 mmu := New(ms.log)
64 f := func(s string) *launch_helper.Notification {
65 card := launch_helper.Card{Summary: "tag: \"" + s + "\"", Persist: true}
66@@ -145,14 +138,8 @@
67 c.Check(mmu.Tags(ms.app), IsNil)
68 c.Assert(mmu.Present(ms.app, "notif1", f("one")), Equals, true)
69 ms.checkTags(c, mmu.Tags(ms.app), []string{"one"})
70- c.Check(existsCount, Equals, 1)
71- existsCount = 0
72-
73 c.Assert(mmu.Present(ms.app, "notif2", f("")), Equals, true)
74 ms.checkTags(c, mmu.Tags(ms.app), []string{"one", ""})
75- c.Check(existsCount, Equals, 2)
76- existsCount = 0
77-
78 // and an empty notification doesn't count
79 c.Assert(mmu.Present(ms.app, "notif3", &launch_helper.Notification{Tag: "X"}), Equals, false)
80 ms.checkTags(c, mmu.Tags(ms.app), []string{"one", ""})
81@@ -163,32 +150,7 @@
82 c.Check(mmu.Tags(ms.app), IsNil)
83 }
84
85-func (ms *MessagingSuite) TestTagsSkipGone(c *C) {
86- existsCount := 0
87- // patch cnotificationexists to return false
88- cNotificationExists = func(did string, nid string) bool {
89- existsCount++
90- return false
91- }
92-
93- mmu := New(ms.log)
94- f := func(s string) *launch_helper.Notification {
95- card := launch_helper.Card{Summary: "tag: \"" + s + "\"", Persist: true}
96- return &launch_helper.Notification{Card: &card, Tag: s}
97- }
98-
99- c.Check(mmu.Tags(ms.app), IsNil)
100- c.Assert(mmu.Present(ms.app, "notif1", f("one")), Equals, true)
101- ms.checkTags(c, mmu.Tags(ms.app), []string(nil))
102- c.Check(existsCount, Equals, 1)
103-}
104-
105 func (ms *MessagingSuite) TestClearClears(c *C) {
106- // patch cnotificationexists to return true
107- cNotificationExists = func(did string, nid string) bool {
108- return true
109- }
110-
111 app1 := ms.app
112 app2 := clickhelp.MustParseAppId("com.example.test_test-2_0")
113 app3 := clickhelp.MustParseAppId("com.example.test_test-3_0")

Subscribers

People subscribed via source and target branches