-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovider_test.go
55 lines (50 loc) · 1.47 KB
/
provider_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
// Copyright (c) Omlox Client Go Contributors
// SPDX-License-Identifier: MIT
package omlox
import (
"encoding/json"
"testing"
)
var providersJSONTestCases = []struct {
name string
provider LocationProvider
json []byte
}{
{
name: "required",
provider: LocationProvider{
ID: "ac:23:3f:ac:a3:87",
Type: LocationProviderTypeUwb,
},
json: []byte(`{"id":"ac:23:3f:ac:a3:87","type":"uwb"}`),
},
{
name: "fully-populated",
provider: LocationProvider{
ID: "ac:23:3f:ac:a3:87",
Type: LocationProviderTypeIbeacon,
Name: "Minew Tag",
Sensors: map[string]any{"temp": float64(65.3)},
FenceTimeout: NewDuration(800),
ExitTolerance: 1.3,
ToleranceTimeout: NewDuration(Inf),
ExitDelay: NewDuration(Inf),
Properties: json.RawMessage(`{"org.wavecom.whereis":{"eid":"MINEW355"}}`),
},
json: []byte(`{"id":"ac:23:3f:ac:a3:87","type":"ibeacon","name":"Minew Tag","sensors":{"temp":65.3},"fence_timeout":800,"exit_tolerance":1.3,"tolerance_timeout":-1,"exit_delay":-1,"properties":{"org.wavecom.whereis":{"eid":"MINEW355"}}}`),
},
}
func TestProviderMarshal(t *testing.T) {
for _, tc := range providersJSONTestCases {
t.Run(tc.name, func(t *testing.T) {
JSONMarshalOK(t, tc.provider, tc.json)
})
}
}
func TestProviderUnmarshal(t *testing.T) {
for _, tc := range providersJSONTestCases {
t.Run(tc.name, func(t *testing.T) {
JSONUnmarshalOK(t, tc.json, tc.provider)
})
}
}