MCPcopy Create free account
hub / github.com/CyCoreSystems/ari-proxy / TestChannelData

Function TestChannelData

internal/integration/channel.go:17–59  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

15var nonEmpty = tmock.MatchedBy(func(s string) bool { return s != "" })
16
17func TestChannelData(t *testing.T, s Server) {
18 key := ari.NewKey(ari.ChannelKey, "c1")
19 runTest("simple", t, s, func(t *testing.T, m *mock, cl ari.Client) {
20 var expected ari.ChannelData
21 expected.ID = "c1"
22 expected.Name = "channe1"
23 expected.State = "Up"
24
25 m.Channel.On("Data", key).Return(&expected, nil)
26
27 cd, err := cl.Channel().Data(key)
28 if err != nil {
29 t.Errorf("Unexpected error in remote Data call %s", err)
30 }
31
32 if cd == nil || cd.ID != expected.ID || cd.Name != expected.Name || cd.State != expected.State {
33 t.Errorf("Expected channel data %v, got %v", expected, cd)
34 }
35
36 m.Shutdown()
37
38 m.Channel.AssertCalled(t, "Data", key)
39 })
40
41 runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) {
42 expected := errors.New("Unknown error")
43
44 m.Channel.On("Data", key).Return(nil, expected)
45
46 cd, err := cl.Channel().Data(key)
47 if err == nil {
48 t.Errorf("Expected error in remote Data call")
49 }
50
51 if cd != nil {
52 t.Errorf("Expected channel data %v, got %v", nil, cd)
53 }
54
55 m.Shutdown()
56
57 m.Channel.AssertCalled(t, "Data", key)
58 })
59}
60
61func TestChannelAnswer(t *testing.T, s Server) {
62 key := ari.NewKey(ari.ChannelKey, "c1")

Callers 2

TestChannelDataFunction · 0.92
TestChannelDataFunction · 0.92

Calls 4

runTestFunction · 0.85
ChannelMethod · 0.80
NewMethod · 0.80
DataMethod · 0.45

Tested by

no test coverage detected