forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig_test.go
54 lines (51 loc) · 1.19 KB
/
config_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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package time
import (
"path/filepath"
"testing"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/operatortest"
)
func TestUnmarshal(t *testing.T) {
operatortest.ConfigUnmarshalTests{
DefaultConfig: NewConfig(),
TestsFile: filepath.Join(".", "testdata", "config.yaml"),
Tests: []operatortest.ConfigUnmarshalTest{
{
Name: "default",
Expect: NewConfig(),
},
{
Name: "on_error_drop",
Expect: func() *Config {
cfg := NewConfig()
cfg.OnError = "drop"
return cfg
}(),
},
{
Name: "parse_strptime",
Expect: func() *Config {
cfg := NewConfig()
from := entry.NewBodyField("from")
cfg.ParseFrom = &from
cfg.LayoutType = "strptime"
cfg.Layout = "%Y-%m-%d"
return cfg
}(),
},
{
Name: "parse_gotime",
Expect: func() *Config {
cfg := NewConfig()
from := entry.NewBodyField("from")
cfg.ParseFrom = &from
cfg.LayoutType = "gotime"
cfg.Layout = "2006-01-02"
return cfg
}(),
},
},
}.Run(t)
}