-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobservers_test.go
55 lines (44 loc) · 1.31 KB
/
observers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package rpc_test
import (
"github.com/juju/testing"
gc "gopkg.in/check.v1"
"github.com/juju/juju/apiserver/observer/fakeobserver"
"github.com/juju/juju/rpc"
)
type multiplexerSuite struct {
testing.IsolationSuite
}
var _ = gc.Suite(&multiplexerSuite{})
func (*multiplexerSuite) TestServerReply_CallsAllObservers(c *gc.C) {
observers := []*fakeobserver.RPCInstance{
(&fakeobserver.Instance{}).RPCObserver().(*fakeobserver.RPCInstance),
(&fakeobserver.Instance{}).RPCObserver().(*fakeobserver.RPCInstance),
}
o := rpc.NewObserverMultiplexer(observers[0], observers[1])
var (
req rpc.Request
hdr rpc.Header
body string
)
o.ServerReply(req, &hdr, body)
for _, f := range observers {
f.CheckCall(c, 0, "ServerReply", req, &hdr, body)
}
}
func (*multiplexerSuite) TestServerRequest_CallsAllObservers(c *gc.C) {
observers := []*fakeobserver.RPCInstance{
(&fakeobserver.Instance{}).RPCObserver().(*fakeobserver.RPCInstance),
(&fakeobserver.Instance{}).RPCObserver().(*fakeobserver.RPCInstance),
}
o := rpc.NewObserverMultiplexer(observers[0], observers[1])
var (
hdr rpc.Header
body string
)
o.ServerRequest(&hdr, body)
for _, f := range observers {
f.CheckCall(c, 0, "ServerRequest", &hdr, body)
}
}