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

Function TestAsteriskVariablesSet

internal/integration/asterisk.go:98–138  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

96}
97
98func TestAsteriskVariablesSet(t *testing.T, s Server) {
99 key := ari.NewKey(ari.VariableKey, "s")
100
101 runTest("simple", t, s, func(t *testing.T, m *mock, cl ari.Client) {
102 var ai ari.AsteriskInfo
103 ai.SystemInfo.EntityID = "1"
104
105 mv := arimocks.AsteriskVariables{}
106 m.Asterisk.On("Variables").Return(&mv)
107 mv.On("Set", key, "hello").Return(nil)
108
109 err := cl.Asterisk().Variables().Set(key, "hello")
110 if err != nil {
111 t.Errorf("Unexpected error in remote Variables Set call: %v", err)
112 }
113
114 m.Shutdown()
115
116 m.Asterisk.AssertCalled(t, "Variables")
117 mv.AssertCalled(t, "Set", key, "hello")
118 })
119
120 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
121 var ai ari.AsteriskInfo
122 ai.SystemInfo.EntityID = "1"
123
124 mv := arimocks.AsteriskVariables{}
125 m.Asterisk.On("Variables").Return(&mv)
126 mv.On("Set", key, "hello").Return(eris.New("error"))
127
128 err := cl.Asterisk().Variables().Set(key, "hello")
129 if err == nil {
130 t.Errorf("Expected error in remote Variables Set call: %v", err)
131 }
132
133 m.Shutdown()
134
135 m.Asterisk.AssertCalled(t, "Variables")
136 mv.AssertCalled(t, "Set", key, "hello")
137 })
138}

Callers 2

TestAsteriskVariablesSetFunction · 0.92
TestAsteriskVariablesSetFunction · 0.92

Calls 5

runTestFunction · 0.85
SetMethod · 0.80
VariablesMethod · 0.80
AsteriskMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected