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

Function TestModulesData

internal/integration/modules.go:96–139  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

94}
95
96func TestModulesData(t *testing.T, s Server) {
97 key := ari.NewKey(ari.ModuleKey, "m1")
98
99 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
100 var d ari.ModuleData
101 d.Description = "Desc"
102 d.Name = "name"
103
104 m.Modules.On("Data", key).Return(&d, nil)
105
106 ret, err := cl.Asterisk().Modules().Data(key)
107 if err != nil {
108 t.Errorf("Unexpected error in module Data: %s", err)
109 }
110 if ret == nil {
111 t.Errorf("Expected module data to be non-nil")
112 } else {
113 if ret.Description != d.Description {
114 t.Errorf("description mismatch: %v %v", ret.Description, d.Description)
115 }
116 if ret.Name != d.Name {
117 t.Errorf("name mismatch: expected '%v', got '%v'", d, ret)
118 }
119 }
120
121 m.Shutdown()
122
123 m.Asterisk.AssertCalled(t, "Modules")
124 m.Modules.AssertCalled(t, "Data", key)
125 })
126 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
127 m.Modules.On("Data", key).Return(nil, errors.New("error"))
128
129 _, err := cl.Asterisk().Modules().Data(key)
130 if err == nil {
131 t.Errorf("Expected error in module Data: %s", err)
132 }
133
134 m.Shutdown()
135
136 m.Asterisk.AssertCalled(t, "Modules")
137 m.Modules.AssertCalled(t, "Data", key)
138 })
139}
140
141func TestModulesList(t *testing.T, s Server) {
142 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {

Callers 2

TestModulesDataFunction · 0.92
TestModulesDataFunction · 0.92

Calls 5

runTestFunction · 0.85
ModulesMethod · 0.80
AsteriskMethod · 0.80
NewMethod · 0.80
DataMethod · 0.45

Tested by

no test coverage detected