-
Notifications
You must be signed in to change notification settings - Fork 2
/
provider_load_test.go
51 lines (38 loc) · 1.32 KB
/
provider_load_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
package zda
import (
"context"
"github.com/shimmeringbee/da/capabilities"
"github.com/shimmeringbee/persistence/impl/memory"
"github.com/shimmeringbee/zigbee"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_gateway_providerLoad(t *testing.T) {
t.Run("loads node, device and capability from persistence", func(t *testing.T) {
s := memory.New()
g := New(context.Background(), s, nil, nil)
g.events = make(chan any, 0xffff)
id := IEEEAddressWithSubIdentifier{IEEEAddress: zigbee.GenerateLocalAdministeredIEEEAddress(), SubIdentifier: 1}
dS := g.sectionForDevice(id)
dS.Set("UniqueId", 5)
cS := dS.Section("Capability", "ProductInformation")
cS.Set("Implementation", "GenericProductInformation")
daS := cS.Section("Data")
daS.Set("Name", "NEXUS-7")
daS.Set("Manufacturer", "Tyrell Corporation")
daS.Set("Serial", "N7FAA52318")
daS.Set("Version", "1.0.0")
g.providerLoad()
d := g.getDevice(id)
assert.Equal(t, d.deviceId, 5)
c := d.Capability(capabilities.ProductInformationFlag)
assert.NotNil(t, c)
cc := c.(capabilities.ProductInformation)
pi, err := cc.Get(context.Background())
assert.NoError(t, err)
assert.Equal(t, "NEXUS-7", pi.Name)
assert.Equal(t, "Tyrell Corporation", pi.Manufacturer)
assert.Equal(t, "N7FAA52318", pi.Serial)
assert.Equal(t, "1.0.0", pi.Version)
})
}