-
Notifications
You must be signed in to change notification settings - Fork 6
/
port_settings_test.go
62 lines (58 loc) · 2.01 KB
/
port_settings_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
package main
import (
"github.com/corbym/gocrest/has"
"github.com/corbym/gocrest/is"
"github.com/corbym/gocrest/then"
"strings"
"testing"
)
func TestFindPortSettingsInHtml(t *testing.T) {
tests := []struct {
model string
fileName string
expectedSettingsLength int
expectedIndex int8
expectedName string
expectedSpeed string
expectedIngressRateLimit string
expectedEgressRateLimit string
expectedFlowControl string
}{
{
model: "GS308EPP",
fileName: "dashboard.cgi.html",
expectedSettingsLength: 8,
expectedIndex: 1,
expectedName: "port name 1",
expectedSpeed: "1",
expectedIngressRateLimit: "1",
expectedEgressRateLimit: "1",
expectedFlowControl: "2",
},
{
model: "GS316EP",
fileName: "dashboard.html",
expectedSettingsLength: 16,
expectedIndex: 1,
expectedName: "port name 1",
expectedSpeed: "Auto",
expectedIngressRateLimit: "No Limit",
expectedEgressRateLimit: "No Limit",
expectedFlowControl: "OFF",
},
}
for _, test := range tests {
t.Run(test.model, func(t *testing.T) {
portSetting, err := findPortSettingsInHtml(NetgearModel(test.model), strings.NewReader(loadTestFile(test.model, test.fileName)))
then.AssertThat(t, err, is.Nil())
then.AssertThat(t, portSetting, has.Length[Port](test.expectedSettingsLength))
setting := portSetting[0]
then.AssertThat(t, setting.Index, is.EqualTo(test.expectedIndex))
then.AssertThat(t, setting.Name, is.EqualTo(test.expectedName))
then.AssertThat(t, setting.Speed, is.EqualTo(test.expectedSpeed))
then.AssertThat(t, setting.IngressRateLimit, is.EqualTo(test.expectedIngressRateLimit))
then.AssertThat(t, setting.EgressRateLimit, is.EqualTo(test.expectedEgressRateLimit))
then.AssertThat(t, setting.FlowControl, is.EqualTo(test.expectedFlowControl))
})
}
}