(t *testing.T, s Server)
| 95 | } |
| 96 | |
| 97 | func TestDeviceList(t *testing.T, s Server) { |
| 98 | runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 99 | h1 := ari.NewKey(ari.DeviceStateKey, "h1") |
| 100 | h2 := ari.NewKey(ari.DeviceStateKey, "h2") |
| 101 | |
| 102 | m.DeviceState.On("List", (*ari.Key)(nil)).Return([]*ari.Key{h1, h2}, nil) |
| 103 | |
| 104 | list, err := cl.DeviceState().List(nil) |
| 105 | if err != nil { |
| 106 | t.Errorf("Error in remote device state List call: %s", err) |
| 107 | } |
| 108 | if len(list) != 2 { |
| 109 | t.Errorf("Expected list of length 2, got %d", len(list)) |
| 110 | } |
| 111 | |
| 112 | m.DeviceState.AssertCalled(t, "List", (*ari.Key)(nil)) |
| 113 | }) |
| 114 | |
| 115 | runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) { |
| 116 | m.DeviceState.On("List", (*ari.Key)(nil)).Return([]*ari.Key{}, errors.New("error")) |
| 117 | |
| 118 | list, err := cl.DeviceState().List(nil) |
| 119 | if err == nil { |
| 120 | t.Errorf("Expected error in remote device state List call") |
| 121 | } |
| 122 | if len(list) != 0 { |
| 123 | t.Errorf("Expected list of length 0, got %d", len(list)) |
| 124 | } |
| 125 | |
| 126 | m.DeviceState.AssertCalled(t, "List", (*ari.Key)(nil)) |
| 127 | }) |
| 128 | } |
no test coverage detected