| 40 | } |
| 41 | |
| 42 | func TestApplicationData(t *testing.T, s Server) { |
| 43 | key := ari.NewKey(ari.ApplicationKey, "1") |
| 44 | runTest("simple", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 45 | ad := &ari.ApplicationData{} |
| 46 | ad.Name = "app1" |
| 47 | |
| 48 | m.Application.On("Data", tmock.Anything).Return(ad, nil) |
| 49 | |
| 50 | res, err := cl.Application().Data(key) |
| 51 | if err != nil { |
| 52 | t.Errorf("Unexpected error in remote Data call: %v", err) |
| 53 | } |
| 54 | if res == nil || res.Name != ad.Name { |
| 55 | t.Errorf("Expected application data name %s, got %s", ad, res) |
| 56 | } |
| 57 | |
| 58 | m.Shutdown() |
| 59 | m.Application.AssertCalled(t, "Data", key) |
| 60 | }) |
| 61 | |
| 62 | runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 63 | expected := eris.New("unknown error") |
| 64 | |
| 65 | m.Application.On("Data", key).Return(nil, expected) |
| 66 | |
| 67 | res, err := cl.Application().Data(key) |
| 68 | if err == nil || eris.Cause(err).Error() != expected.Error() { |
| 69 | t.Errorf("Expected error '%v', got '%v'", expected, err) |
| 70 | } |
| 71 | if res != nil { |
| 72 | t.Errorf("Expected application data result to be empty, got %s", res) |
| 73 | } |
| 74 | |
| 75 | m.Shutdown() |
| 76 | |
| 77 | m.Application.AssertCalled(t, "Data", key) |
| 78 | }) |
| 79 | } |
| 80 | |
| 81 | func TestApplicationSubscribe(t *testing.T, s Server) { |
| 82 | key := ari.NewKey(ari.ApplicationKey, "1") |