(t *testing.T, s Server)
| 15 | var nonEmpty = tmock.MatchedBy(func(s string) bool { return s != "" }) |
| 16 | |
| 17 | func TestChannelData(t *testing.T, s Server) { |
| 18 | key := ari.NewKey(ari.ChannelKey, "c1") |
| 19 | runTest("simple", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 20 | var expected ari.ChannelData |
| 21 | expected.ID = "c1" |
| 22 | expected.Name = "channe1" |
| 23 | expected.State = "Up" |
| 24 | |
| 25 | m.Channel.On("Data", key).Return(&expected, nil) |
| 26 | |
| 27 | cd, err := cl.Channel().Data(key) |
| 28 | if err != nil { |
| 29 | t.Errorf("Unexpected error in remote Data call %s", err) |
| 30 | } |
| 31 | |
| 32 | if cd == nil || cd.ID != expected.ID || cd.Name != expected.Name || cd.State != expected.State { |
| 33 | t.Errorf("Expected channel data %v, got %v", expected, cd) |
| 34 | } |
| 35 | |
| 36 | m.Shutdown() |
| 37 | |
| 38 | m.Channel.AssertCalled(t, "Data", key) |
| 39 | }) |
| 40 | |
| 41 | runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 42 | expected := errors.New("Unknown error") |
| 43 | |
| 44 | m.Channel.On("Data", key).Return(nil, expected) |
| 45 | |
| 46 | cd, err := cl.Channel().Data(key) |
| 47 | if err == nil { |
| 48 | t.Errorf("Expected error in remote Data call") |
| 49 | } |
| 50 | |
| 51 | if cd != nil { |
| 52 | t.Errorf("Expected channel data %v, got %v", nil, cd) |
| 53 | } |
| 54 | |
| 55 | m.Shutdown() |
| 56 | |
| 57 | m.Channel.AssertCalled(t, "Data", key) |
| 58 | }) |
| 59 | } |
| 60 | |
| 61 | func TestChannelAnswer(t *testing.T, s Server) { |
| 62 | key := ari.NewKey(ari.ChannelKey, "c1") |
no test coverage detected