| 79 | } |
| 80 | |
| 81 | func TestApplicationSubscribe(t *testing.T, s Server) { |
| 82 | key := ari.NewKey(ari.ApplicationKey, "1") |
| 83 | |
| 84 | runTest("simple", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 85 | m.Application.On("Subscribe", key, "2").Return(nil) |
| 86 | |
| 87 | if err := cl.Application().Subscribe(key, "2"); err != nil { |
| 88 | t.Errorf("Unexpected error in remote Subscribe call: %v", err) |
| 89 | } |
| 90 | |
| 91 | m.Shutdown() |
| 92 | |
| 93 | m.Application.AssertCalled(t, "Subscribe", key, "2") |
| 94 | }) |
| 95 | |
| 96 | runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 97 | expected := eris.New("unknown error") |
| 98 | |
| 99 | m.Application.On("Subscribe", key, "2").Return(expected) |
| 100 | |
| 101 | if err := cl.Application().Subscribe(key, "2"); err == nil || eris.Cause(err).Error() != expected.Error() { |
| 102 | t.Errorf("Expected error '%v', got '%v'", expected, err) |
| 103 | } |
| 104 | |
| 105 | m.Shutdown() |
| 106 | |
| 107 | m.Application.AssertCalled(t, "Subscribe", key, "2") |
| 108 | }) |
| 109 | } |
| 110 | |
| 111 | func TestApplicationUnsubscribe(t *testing.T, s Server) { |
| 112 | key := ari.NewKey(ari.ApplicationKey, "1") |