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

Function TestConfigUpdate

internal/integration/config.go:108–149  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

106}
107
108func TestConfigUpdate(t *testing.T, s Server) {
109 key := ari.NewKey("config", ari.ConfigID("c1", "o1", "id1"))
110
111 tuples := []ari.ConfigTuple{
112 ari.ConfigTuple{
113 Value: "v1",
114 Attribute: "a1",
115 },
116 ari.ConfigTuple{
117 Value: "v2",
118 Attribute: "a2",
119 },
120 }
121
122 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
123 cfg := arimocks.Config{}
124 m.Asterisk.On("Config").Return(&cfg)
125 cfg.On("Update", key, tuples).Return(nil)
126
127 err := cl.Asterisk().Config().Update(key, tuples)
128 if err != nil {
129 t.Errorf("Unexpected error in remove config Update call: %s", err)
130 }
131
132 m.Asterisk.AssertCalled(t, "Config")
133 cfg.AssertCalled(t, "Update", key, tuples)
134 })
135
136 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
137 cfg := arimocks.Config{}
138 m.Asterisk.On("Config").Return(&cfg)
139 cfg.On("Update", key, tuples).Return(errors.New("error"))
140
141 err := cl.Asterisk().Config().Update(key, tuples)
142 if err == nil {
143 t.Errorf("Expected error in remove config Update call")
144 }
145
146 m.Asterisk.AssertCalled(t, "Config")
147 cfg.AssertCalled(t, "Update", key, tuples)
148 })
149}

Callers 2

TestConfigUpdateFunction · 0.92
TestConfigUpdateFunction · 0.92

Calls 5

runTestFunction · 0.85
ConfigMethod · 0.80
AsteriskMethod · 0.80
NewMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected