Debian Codegraph @

server/broker/simple/simple_test.go

raw
1 /*
2 Copyright 2013-2014 Canonical Ltd.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License version 3, as published
6 by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranties of
10 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 package simple
18
19 import (
20 stdtesting "testing"
21
22 . "gopkg.in/check.v1"
23
24 "gitlab.com/ubports/development/core/lomiri-push-service/server/broker/testing"
25 "gitlab.com/ubports/development/core/lomiri-push-service/server/store"
26 )
27
28 func TestSimple(t *stdtesting.T) { TestingT(t) }
29
30 type simpleSuite struct{}
31
32 var _ = Suite(&simpleSuite{})
33
34 var testBrokerConfig = &testing.TestBrokerConfig{10, 5}
35
36 func (s *simpleSuite) TestNew(c *C) {
37 sto := store.NewInMemoryPendingStore()
38 b := NewSimpleBroker(sto, testBrokerConfig, nil, nil)
39 c.Check(cap(b.sessionCh), Equals, 5)
40 c.Check(len(b.registry), Equals, 0)
41 c.Check(b.sto, Equals, sto)
42 }
43
44 func (s *simpleSuite) TestSessionInternalChannelId(c *C) {
45 sess := &simpleBrokerSession{deviceId: "dev21"}
46 c.Check(sess.InternalChannelId(), Equals, store.UnicastInternalChannelId("dev21", "dev21"))
47 }