-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrive_test.go
51 lines (42 loc) · 1.25 KB
/
drive_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 drive
import (
"testing"
"github.com/NETWAYS/go-check"
"github.com/stretchr/testify/assert"
)
const affectedDrive = "VO0480JFDGT"
const affectedDriveFixed = "HPD8"
func TestPhysicalDrive_GetNagiosStatus(t *testing.T) {
drive := &PhysicalDrive{
ID: "1.1",
Model: "OTHERDRIVE",
FwRev: "HPD1",
Serial: "ABC123",
Status: "ok",
Hours: 1337,
}
var (
status int
info string
)
// good
status, info = drive.GetNagiosStatus()
assert.Equal(t, check.OK, status)
assert.Regexp(t, `\(1\.1 \) model=\w+ serial=ABC123 firmware=HPD1 hours=1337`, info)
// failed
drive.Status = "failed"
status, info = drive.GetNagiosStatus()
assert.Equal(t, check.Critical, status)
assert.Regexp(t, `\(1\.1 \) model=\w+ serial=ABC123 firmware=HPD1 hours=1337 - status: failed`, info)
// affected
drive.Status = "ok"
drive.Model = affectedDrive
status, info = drive.GetNagiosStatus()
assert.Equal(t, check.Critical, status)
assert.Regexp(t, `\(1\.1 \) model=\w+ serial=ABC123 firmware=HPD1 hours=1337 - affected`, info)
// affected but fixed
drive.FwRev = affectedDriveFixed
status, info = drive.GetNagiosStatus()
assert.Equal(t, check.OK, status)
assert.Regexp(t, `\(1\.1 \) model=\w+ serial=ABC123 firmware=\w+ hours=1337 - .*applied`, info)
}