-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain_test.go
38 lines (34 loc) · 1013 Bytes
/
main_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
package main
import (
"testing"
"github.com/sensu-community/sensu-plugin-sdk/sensu"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/stretchr/testify/assert"
)
func TestMain(t *testing.T) {
}
func TestCheckArgs(t *testing.T) {
assert := assert.New(t)
event := corev2.FixtureEvent("entity1", "check1")
plugin.IncludeFSType = []string{"ext4", "xfs}"}
plugin.ExcludeFSType = []string{"tmpfs", "devtmpfs"}
i, e := checkArgs(event)
assert.Equal(sensu.CheckStateCritical, i)
assert.Error(e)
plugin.ExcludeFSType = []string{}
plugin.IncludeFSPath = []string{"/", "/home"}
plugin.ExcludeFSPath = []string{"/tmp"}
i, e = checkArgs(event)
assert.Equal(sensu.CheckStateCritical, i)
assert.Error(e)
plugin.ExcludeFSPath = []string{}
plugin.Warning = float64(80)
plugin.Critical = float64(70)
i, e = checkArgs(event)
assert.Equal(sensu.CheckStateCritical, i)
assert.Error(e)
plugin.Critical = float64(90)
i, e = checkArgs(event)
assert.Equal(sensu.CheckStateOK, i)
assert.NoError(e)
}