forked from aquasecurity/tracee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
53 lines (47 loc) · 1.29 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"bytes"
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/aquasecurity/tracee/tracee-rules/types"
)
func Test_listSigs(t *testing.T) {
fakeSigs := []fakeSignature{
{
getMetadata: func() (types.SignatureMetadata, error) {
return types.SignatureMetadata{
ID: "FOO-1",
Version: "1.2.3",
Name: "foo signature",
Description: "foo signature helps with foo",
}, nil
},
},
{
getMetadata: func() (types.SignatureMetadata, error) {
return types.SignatureMetadata{
ID: "BAR-1",
Version: "4.5.6",
Name: "bar signature",
Description: "bar signature helps with bar",
}, nil
},
},
{
getMetadata: func() (types.SignatureMetadata, error) {
return types.SignatureMetadata{}, errors.New("baz failed")
},
},
}
var inputSigs []types.Signature
for _, fs := range fakeSigs {
inputSigs = append(inputSigs, fs)
}
buf := bytes.Buffer{}
assert.NoError(t, listSigs(&buf, inputSigs))
assert.Equal(t, `ID NAME VERSION DESCRIPTION
FOO-1 foo signature 1.2.3 foo signature helps with foo
BAR-1 bar signature 4.5.6 bar signature helps with bar
`, buf.String())
}