| 96 | } |
| 97 | |
| 98 | func 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 | } |