(t *testing.T, s Server)
| 9 | ) |
| 10 | |
| 11 | func TestLiveRecordingData(t *testing.T, s Server) { |
| 12 | runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 13 | expected := ari.LiveRecordingData{ |
| 14 | Name: "n1", |
| 15 | Format: "format", |
| 16 | Cause: "c1", |
| 17 | Silence: ari.DurationSec(3 * time.Second), |
| 18 | State: "st1", |
| 19 | Talking: ari.DurationSec(3 * time.Second), |
| 20 | TargetURI: "uri1", |
| 21 | Duration: ari.DurationSec(6 * time.Second), |
| 22 | } |
| 23 | |
| 24 | key := ari.NewKey(ari.LiveRecordingKey, "lr1") |
| 25 | |
| 26 | m.LiveRecording.On("Data", key).Return(&expected, nil) |
| 27 | |
| 28 | ret, err := cl.LiveRecording().Data(key) |
| 29 | if err != nil { |
| 30 | t.Errorf("Unexpected error in liverecording Data: %s", err) |
| 31 | } |
| 32 | if ret == nil { |
| 33 | t.Errorf("Expected live recording data to be non-nil") |
| 34 | } else { |
| 35 | failed := false |
| 36 | failed = failed || ret.Name != expected.Name |
| 37 | failed = failed || ret.Format != expected.Format |
| 38 | failed = failed || ret.Cause != expected.Cause |
| 39 | failed = failed || ret.Silence != expected.Silence |
| 40 | failed = failed || ret.State != expected.State |
| 41 | failed = failed || ret.Talking != expected.Talking |
| 42 | failed = failed || ret.TargetURI != expected.TargetURI |
| 43 | failed = failed || ret.Duration != expected.Duration |
| 44 | if failed { |
| 45 | t.Errorf("Expected '%v', got '%v'", expected, ret) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | m.LiveRecording.AssertCalled(t, "Data", key) |
| 50 | }) |
| 51 | runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 52 | key := ari.NewKey(ari.LiveRecordingKey, "lr1") |
| 53 | |
| 54 | m.LiveRecording.On("Data", key).Return(nil, errors.New("err")) |
| 55 | |
| 56 | ret, err := cl.LiveRecording().Data(key) |
| 57 | if err == nil { |
| 58 | t.Errorf("Expected error in liverecording Data") |
| 59 | } |
| 60 | if ret != nil { |
| 61 | t.Errorf("Expected live recording data to be nil") |
| 62 | } |
| 63 | |
| 64 | m.LiveRecording.AssertCalled(t, "Data", key) |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | func testLiveRecordingCommand(t *testing.T, m *mock, name string, id *ari.Key, expected error, fn func(*ari.Key) error) { |
no test coverage detected