-
Notifications
You must be signed in to change notification settings - Fork 3
/
GetDeviceInfo_test.go
59 lines (52 loc) · 1.13 KB
/
GetDeviceInfo_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
package netgear_client
import (
"fmt"
"testing"
)
func TestGetInfo(t *testing.T) {
debug := true
if get_password() == "" {
t.Fatal("Error: NETGEAR_PASSWORD environment variable is not set")
}
client, err := NewNetgearClient(get_url(), true, get_username(), get_password(), 5, debug)
if err != nil {
t.Fatalf("Error getting a client: %s", err)
}
res, err := client.GetDeviceInfo()
if err != nil {
t.Fatalf("Error getting device info: %s", err)
}
if len(res) == 0 {
t.Fatalf("Unexpected empty response")
}
expected := [...]string{
"Description",
"DeviceMode",
"DeviceModeCapability",
"DeviceName",
"DeviceNameUserSet",
"FirewallVersion",
"FirmwareDLmethod",
"FirmwareLastChecked",
"FirmwareLastUpdate",
"Firmwareversion",
"FirstUseDate",
"ModelName",
"Otherhardwareversion",
"OthersoftwareVersion",
"SerialNumber",
"SignalStrength",
"SmartAgentversion",
"VPNVersion",
}
for _, key := range expected {
if _, ok := res[key]; !ok {
t.Errorf("Expected `%s` key in the response, but did not find it", key)
}
}
if debug {
for k, v := range res {
fmt.Printf("%v => %v\n", k, v)
}
}
}