-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_test.go
More file actions
48 lines (39 loc) · 1.04 KB
/
config_test.go
File metadata and controls
48 lines (39 loc) · 1.04 KB
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
package tracebasedlogsampler
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
)
func TestLoadConfig(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "sample_config.yaml"))
assert.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(typeStr, "").String())
assert.NoError(t, err)
require.NoError(t, sub.Unmarshal(cfg))
assert.Equal(t, &Config{
BufferDurationTraces: "180s",
BufferDurationLogs: "90s",
}, cfg)
}
func TestValidate(t *testing.T) {
cfg := &Config{
BufferDurationTraces: "0",
BufferDurationLogs: "10s",
}
assert.Error(t, cfg.Validate())
cfg = &Config{
BufferDurationTraces: "10s",
BufferDurationLogs: "0",
}
assert.Error(t, cfg.Validate())
cfg = &Config{
BufferDurationTraces: "10s",
BufferDurationLogs: "10s",
}
assert.NoError(t, cfg.Validate())
}