-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroller_test.go
58 lines (54 loc) · 1.37 KB
/
controller_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
package cntlr
import (
"testing"
"github.com/NETWAYS/go-check"
"github.com/stretchr/testify/assert"
)
func TestIlo_GetNagiosStatus(t *testing.T) {
testcases := map[string]struct {
controller Controller
expectedState int
expectedOutput string
}{
"status-ok": {
controller: Controller{
ID: "id123",
Model: "model",
FwRev: "revision",
Serial: "12345",
Status: "ok",
},
expectedState: check.OK,
expectedOutput: "controller (id123) model=model serial=12345 firmware=revision",
},
"status-not-ok-not-affected": {
controller: Controller{
ID: "id123",
Model: "model",
FwRev: "revision",
Serial: "12345",
Status: "not-ok",
},
expectedState: check.Critical,
expectedOutput: "controller (id123) model=model serial=12345 firmware=revision",
},
"status-not-ok-affected": {
controller: Controller{
ID: "id123",
Model: "e208i-p",
FwRev: "1.98",
Serial: "12345",
Status: "ok",
},
expectedState: check.Critical,
expectedOutput: "controller (id123) model=e208i-p serial=12345 firmware=1.98 - if you have RAID 5/6/50/60 - update immediately!",
},
}
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
state, output := tc.controller.GetNagiosStatus()
assert.Equal(t, state, tc.expectedState)
assert.Contains(t, output, tc.expectedOutput)
})
}
}