-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_test.go
65 lines (57 loc) · 1.39 KB
/
stats_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
59
60
61
62
63
64
65
package stat
import (
"context"
"testing"
"time"
"github.com/asecurityteam/settings/v2"
"github.com/stretchr/testify/require"
)
func TestNullComponent(t *testing.T) {
cmp := &NullComponent{}
conf := cmp.Settings()
tr, err := cmp.New(context.Background(), conf)
require.Nil(t, err)
require.NotNil(t, tr)
}
func TestDatadogComponentBadConfig(t *testing.T) {
cmp := &DatadogComponent{}
conf := cmp.Settings()
conf.Address = ""
_, err := cmp.New(context.Background(), conf)
require.NotNil(t, err)
}
func TestDatadogComponent(t *testing.T) {
cmp := &DatadogComponent{}
conf := cmp.Settings()
tr, err := cmp.New(context.Background(), conf)
require.Nil(t, err)
require.NotNil(t, tr)
}
func TestComponent(t *testing.T) {
src := settings.NewMapSource(map[string]interface{}{
"stats": map[string]interface{}{
"output": "NULL",
},
})
tr, err := New(context.Background(), src)
require.Nil(t, err)
require.NotNil(t, tr)
src = settings.NewMapSource(map[string]interface{}{
"stats": map[string]interface{}{
"output": "DATADOG",
"datadog": map[string]interface{}{
"flushinterval": 10 * time.Second,
},
},
})
tr, err = New(context.Background(), src)
require.Nil(t, err)
require.NotNil(t, tr)
src = settings.NewMapSource(map[string]interface{}{
"stats": map[string]interface{}{
"output": "MISSING",
},
})
_, err = New(context.Background(), src)
require.NotNil(t, err)
}