-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin_test.go
67 lines (61 loc) · 1.22 KB
/
plugin_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
66
67
package fluentbitconfig
import (
"testing"
"github.com/alecthomas/assert/v2"
"github.com/calyptia/go-fluentbit-config/v2/property"
)
func TestPlugins_IDs(t *testing.T) {
t.Run("ok", func(t *testing.T) {
conf, err := ParseAs(`
[INPUT]
name cpu
[INPUT]
name mem
[INPUT]
name cpu
`, FormatClassic)
assert.NoError(t, err)
assert.Equal(t, []string{
"cpu.0",
"mem.1",
"cpu.2",
}, conf.Pipeline.Inputs.IDs())
})
}
func TestPlugins_FindByID(t *testing.T) {
t.Run("not_found", func(t *testing.T) {
conf, err := ParseAs(`
[INPUT]
name cpu
[INPUT]
name mem
[INPUT]
name cpu
`, FormatClassic)
assert.NoError(t, err)
_, found := conf.Pipeline.Inputs.FindByID("cpu.1")
assert.False(t, found)
})
t.Run("ok", func(t *testing.T) {
conf, err := ParseAs(`
[INPUT]
name cpu
[INPUT]
name mem
[INPUT]
name cpu
proptest valuetest
`, FormatClassic)
assert.NoError(t, err)
plugin, found := conf.Pipeline.Inputs.FindByID("cpu.2")
assert.True(t, found)
assert.Equal(t, Plugin{
ID: "cpu.2",
Name: "cpu",
Properties: []property.Property{
{Key: "name", Value: "cpu"},
{Key: "proptest", Value: "valuetest"},
},
}, plugin)
})
}