-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiota-device_test.go
81 lines (71 loc) · 1.37 KB
/
iota-device_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package iotagentsdk_test
import (
"testing"
i "github.com/fbuedding/fiware-iot-agent-sdk"
)
func TestReadDevice(t *testing.T) {
respD, err := iota.ReadDevice(fs, deviceId)
if err != nil {
t.Error(err)
}
if respD.EntityName != entityName {
t.Fail()
}
}
func TestListDevice(t *testing.T) {
respD, err := iota.ListDevices(fs)
if err != nil {
t.Error(err)
}
if respD.Count != 1 {
t.Fail()
}
if respD.Devices[0].EntityName != entityName {
t.Fail()
}
}
func TestUpdateDevice(t *testing.T) {
dtmp := d
dtmp.EntityName = updatedEntityName
dtmp.EntityType = "test"
dtmp.Transport = "MQTT"
err := iota.UpdateDevice(fs, dtmp)
if err != nil {
t.Error(err)
}
dUpdated, _ := iota.ReadDevice(fs, d.Id)
if dUpdated.EntityName != updatedEntityName {
t.Fail()
}
dtmp1 := i.Device{Id: deviceId}
err = iota.UpdateDevice(fs, dtmp1)
if err != nil {
t.Log("Device shouldn't updatet empty body")
t.Error(err)
}
}
func TestDeleteDevice(t *testing.T) {
err := iota.DeleteDevice(fs, d.Id)
if err != nil {
t.Error(err)
}
}
func TestUpsertDevice(t *testing.T) {
err := iota.UpsertDevice(fs, d)
if err != nil {
t.Error(err)
}
err = iota.UpsertDevice(fs, d)
if err != nil {
t.Error(err)
}
iota.DeleteDevice(fs, d.Id)
}
func TestCreateDeviceWSE(t *testing.T) {
dtemp := d
err := iota.CreateDeviceWSE(fs, &dtemp)
if err != nil {
t.Error(err)
}
t.Log(dtemp)
}