-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain_test.go
30 lines (24 loc) · 966 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
package main
import (
"testing"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/stretchr/testify/assert"
)
func TestMain(t *testing.T) {
}
func TestParseSearches(t *testing.T) {
assert := assert.New(t)
searches := `[{"full_cmdline": true, "number": 1, "severity": 1, "search_string": "eventmonitor"}, {"number": 1, "severity": 2, "search_string": "ssh-agent"}, {"number": 2, "severity": 1, "search_string": "non-existent"}]`
s, err := parseSearches(searches)
assert.NoError(err)
assert.Equal(3, len(s))
}
func TestCheckArgs(t *testing.T) {
assert := assert.New(t)
event := corev2.FixtureEvent("entity1", "check1")
_, err := checkArgs(event)
assert.Error(err)
plugin.Search = `[{"full_cmdline": true, "number": 1, "severity": 1, "search_string": "eventmonitor"}, {"number": 1, "severity": 2, "search_string": "ssh-agent"}, {"number": 2, "severity": 1, "search_string": "non-existent"}]`
_, err = checkArgs(event)
assert.NoError(err)
}