MCPcopy Create free account
hub / github.com/CyCoreSystems/ari-proxy / TestDeviceList

Function TestDeviceList

internal/integration/device.go:97–128  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

95}
96
97func 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}

Callers 2

TestDeviceListFunction · 0.92
TestDeviceListFunction · 0.92

Calls 4

runTestFunction · 0.85
DeviceStateMethod · 0.80
NewMethod · 0.80
ListMethod · 0.65

Tested by

no test coverage detected