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

Function TestDeviceData

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

Source from the content-addressed store, hash-verified

8)
9
10func TestDeviceData(t *testing.T, s Server) {
11 key := ari.NewKey(ari.DeviceStateKey, "d1")
12 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
13 var expected ari.DeviceStateData
14 expected.State = "deviceData1"
15 expected.Key = ari.NewKey(ari.DeviceStateKey, "d1")
16
17 m.DeviceState.On("Data", key).Return(&expected, nil)
18
19 data, err := cl.DeviceState().Data(key)
20 if err != nil {
21 t.Errorf("Error in remote device state data call: %s", err)
22 }
23 if data == nil || data.State != expected.State {
24 t.Errorf("Expected data '%s', got '%v'", expected, data)
25 }
26
27 m.DeviceState.AssertCalled(t, "Data", key)
28 })
29
30 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
31 m.DeviceState.On("Data", key).Return(nil, errors.New("err"))
32
33 data, err := cl.DeviceState().Data(key)
34 if err == nil {
35 t.Errorf("Expected error in remote device state data call: %s", err)
36 }
37 if data != nil {
38 t.Errorf("Expected data to be nil, got '%v'", *data)
39 }
40
41 m.DeviceState.AssertCalled(t, "Data", key)
42 })
43}
44
45func TestDeviceDelete(t *testing.T, s Server) {
46 key := ari.NewKey(ari.DeviceStateKey, "d1")

Callers 2

TestDeviceDataFunction · 0.92
TestDeviceDataFunction · 0.92

Calls 4

runTestFunction · 0.85
DeviceStateMethod · 0.80
NewMethod · 0.80
DataMethod · 0.45

Tested by

no test coverage detected