| 74 | } |
| 75 | |
| 76 | func TestConfigDelete(t *testing.T, s Server) { |
| 77 | key := ari.NewKey("config", ari.ConfigID("c1", "o1", "id1")) |
| 78 | |
| 79 | runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 80 | cfg := arimocks.Config{} |
| 81 | m.Asterisk.On("Config").Return(&cfg) |
| 82 | cfg.On("Delete", key).Return(nil) |
| 83 | |
| 84 | err := cl.Asterisk().Config().Delete(key) |
| 85 | if err != nil { |
| 86 | t.Errorf("Unexpected error in remove config delete call: %s", err) |
| 87 | } |
| 88 | |
| 89 | m.Asterisk.AssertCalled(t, "Config") |
| 90 | cfg.AssertCalled(t, "Delete", key) |
| 91 | }) |
| 92 | |
| 93 | runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 94 | cfg := arimocks.Config{} |
| 95 | m.Asterisk.On("Config").Return(&cfg) |
| 96 | cfg.On("Delete", key).Return(errors.New("error")) |
| 97 | |
| 98 | err := cl.Asterisk().Config().Delete(key) |
| 99 | if err == nil { |
| 100 | t.Errorf("Expected error in remove config delete call") |
| 101 | } |
| 102 | |
| 103 | m.Asterisk.AssertCalled(t, "Config") |
| 104 | cfg.AssertCalled(t, "Delete", key) |
| 105 | }) |
| 106 | } |
| 107 | |
| 108 | func TestConfigUpdate(t *testing.T, s Server) { |
| 109 | key := ari.NewKey("config", ari.ConfigID("c1", "o1", "id1")) |