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

Function TestModulesList

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

Source from the content-addressed store, hash-verified

139}
140
141func TestModulesList(t *testing.T, s Server) {
142 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
143 m1 := ari.NewKey(ari.ModuleKey, "m1")
144 m2 := ari.NewKey(ari.ModuleKey, "m2")
145
146 m.Modules.On("List", (*ari.Key)(nil)).Return([]*ari.Key{m1, m2}, nil)
147
148 ret, err := cl.Asterisk().Modules().List(nil)
149 if err != nil {
150 t.Errorf("Unepected error in module List: %s", err)
151 }
152 if len(ret) != 2 {
153 t.Errorf("Expected handle list length of size '2', got '%d'", len(ret))
154 }
155
156 m.Shutdown()
157
158 m.Asterisk.AssertCalled(t, "Modules")
159 m.Modules.AssertCalled(t, "List", (*ari.Key)(nil))
160 })
161 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
162 m.Modules.On("List", (*ari.Key)(nil)).Return([]*ari.Key{}, errors.New("error"))
163
164 _, err := cl.Asterisk().Modules().List(nil)
165 if err == nil {
166 t.Errorf("Expected error in module List")
167 }
168
169 m.Shutdown()
170
171 m.Asterisk.AssertCalled(t, "Modules")
172 m.Modules.AssertCalled(t, "List", (*ari.Key)(nil))
173 })
174}

Callers 2

TestModulesListFunction · 0.92
TestModulesListFunction · 0.92

Calls 5

runTestFunction · 0.85
ModulesMethod · 0.80
AsteriskMethod · 0.80
NewMethod · 0.80
ListMethod · 0.65

Tested by

no test coverage detected