| 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 |
. "gopkg.in/check.v1" |
| 21 |
|
| 22 |
"gitlab.com/ubports/development/core/lomiri-push-service/logger" |
| 23 |
"gitlab.com/ubports/development/core/lomiri-push-service/server/broker" |
| 24 |
"gitlab.com/ubports/development/core/lomiri-push-service/server/broker/testsuite" |
| 25 |
"gitlab.com/ubports/development/core/lomiri-push-service/server/store" |
| 26 |
) |
| 27 |
|
| 28 |
// run the common broker test suite against SimpleBroker |
| 29 |
|
| 30 |
// aliasing through embedding to get saner report names by gocheck |
| 31 |
type commonBrokerSuite struct { |
| 32 |
testsuite.CommonBrokerSuite |
| 33 |
} |
| 34 |
|
| 35 |
// trivial session tracker |
| 36 |
type testTracker string |
| 37 |
|
| 38 |
func (t testTracker) SessionId() string { |
| 39 |
return string(t) |
| 40 |
} |
| 41 |
|
| 42 |
var _ = Suite(&commonBrokerSuite{testsuite.CommonBrokerSuite{ |
| 43 |
MakeBroker: func(sto store.PendingStore, cfg broker.BrokerConfig, log logger.Logger) testsuite.FullBroker { |
| 44 |
return NewSimpleBroker(sto, cfg, log, nil) |
| 45 |
}, |
| 46 |
MakeTracker: func(sessionId string) broker.SessionTracker { |
| 47 |
return testTracker(sessionId) |
| 48 |
}, |
| 49 |
RevealSession: func(b broker.Broker, deviceId string) broker.BrokerSession { |
| 50 |
return b.(*SimpleBroker).registry[deviceId] |
| 51 |
}, |
| 52 |
RevealBroadcastExchange: func(exchg broker.Exchange) *broker.BroadcastExchange { |
| 53 |
return exchg.(*broker.BroadcastExchange) |
| 54 |
}, |
| 55 |
RevealUnicastExchange: func(exchg broker.Exchange) *broker.UnicastExchange { |
| 56 |
return exchg.(*broker.UnicastExchange) |
| 57 |
}, |
| 58 |
}}) |