Merge lp:~pedronis/ubuntu-push/improve-coverage into lp:ubuntu-push

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 45
Merged at revision: 43
Proposed branch: lp:~pedronis/ubuntu-push/improve-coverage
Merge into: lp:ubuntu-push
Diff against target: 110 lines (+46/-6)
5 files modified
server/api/handlers.go (+2/-2)
server/api/handlers_test.go (+10/-0)
server/broker/broker_test.go (+34/-0)
server/broker/simple_test.go (+0/-3)
server/session/session.go (+0/-1)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/improve-coverage
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+201650@code.launchpad.net

Commit message

couple of extra tests and changes to improve test coverage

Description of the change

couple of extra tests and changes to improve test coverage

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'server/api/handlers.go'
2--- server/api/handlers.go 2014-01-13 15:21:11 +0000
3+++ server/api/handlers.go 2014-01-14 19:03:52 +0000
4@@ -161,7 +161,7 @@
5 return nil
6 }
7
8-func readBody(writer http.ResponseWriter, request *http.Request) ([]byte, *APIError) {
9+func readBody(request *http.Request) ([]byte, *APIError) {
10 if err := checkRequestAsPost(request); err != nil {
11 return nil, err
12 }
13@@ -207,7 +207,7 @@
14 }
15
16 func (h *BroadcastHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
17- body, apiErr := readBody(writer, request)
18+ body, apiErr := readBody(request)
19
20 if apiErr != nil {
21 respondError(writer, apiErr)
22
23=== modified file 'server/api/handlers_test.go'
24--- server/api/handlers_test.go 2014-01-13 15:21:11 +0000
25+++ server/api/handlers_test.go 2014-01-14 19:03:52 +0000
26@@ -53,6 +53,16 @@
27 c.Check(string(wire), Equals, `{"error":"invalid-request","message":"Message"}`)
28 }
29
30+func (s *handlersSuite) TestReadyBodyReadError(c *C) {
31+ r := bytes.NewReader([]byte{}) // eof too early
32+ req, err := http.NewRequest("POST", "", r)
33+ req.Header.Set("Content-Type", "application/json")
34+ req.ContentLength = 1000
35+ c.Assert(err, IsNil)
36+ _, err = readBody(req)
37+ c.Check(err, Equals, ErrCouldNotReadBody)
38+}
39+
40 type checkBrokerSending struct {
41 store store.PendingStore
42 chanId store.InternalChannelId
43
44=== added file 'server/broker/broker_test.go'
45--- server/broker/broker_test.go 1970-01-01 00:00:00 +0000
46+++ server/broker/broker_test.go 2014-01-14 19:03:52 +0000
47@@ -0,0 +1,34 @@
48+/*
49+ Copyright 2013-2014 Canonical Ltd.
50+
51+ This program is free software: you can redistribute it and/or modify it
52+ under the terms of the GNU General Public License version 3, as published
53+ by the Free Software Foundation.
54+
55+ This program is distributed in the hope that it will be useful, but
56+ WITHOUT ANY WARRANTY; without even the implied warranties of
57+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
58+ PURPOSE. See the GNU General Public License for more details.
59+
60+ You should have received a copy of the GNU General Public License along
61+ with this program. If not, see <http://www.gnu.org/licenses/>.
62+*/
63+
64+package broker
65+
66+import (
67+ "fmt"
68+ . "launchpad.net/gocheck"
69+ "testing"
70+)
71+
72+func TestBroker(t *testing.T) { TestingT(t) }
73+
74+type brokerSuite struct{}
75+
76+var _ = Suite(&brokerSuite{})
77+
78+func (s *brokerSuite) TestErrAbort(c *C) {
79+ err := &ErrAbort{"expected FOO"}
80+ c.Check(fmt.Sprintf("%s", err), Equals, "session aborted (expected FOO)")
81+}
82
83=== modified file 'server/broker/simple_test.go'
84--- server/broker/simple_test.go 2014-01-13 15:21:11 +0000
85+++ server/broker/simple_test.go 2014-01-14 19:03:52 +0000
86@@ -25,12 +25,9 @@
87 "launchpad.net/ubuntu-push/server/store"
88 helpers "launchpad.net/ubuntu-push/testing"
89 // "log"
90- "testing"
91 "time"
92 )
93
94-func TestSimple(t *testing.T) { TestingT(t) }
95-
96 type simpleSuite struct{}
97
98 var _ = Suite(&simpleSuite{})
99
100=== modified file 'server/session/session.go'
101--- server/session/session.go 2014-01-13 15:21:11 +0000
102+++ server/session/session.go 2014-01-14 19:03:52 +0000
103@@ -107,7 +107,6 @@
104 }
105 }
106 }
107- return nil
108 }
109
110 var sessionsEpoch = time.Date(2013, 1, 1, 0, 0, 0, 0, time.UTC).UnixNano()

Subscribers

People subscribed via source and target branches