|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +package stripansiescapecodes |
| 4 | + |
| 5 | +import ( |
| 6 | + "path/filepath" |
| 7 | + "testing" |
| 8 | + |
| 9 | + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry" |
| 10 | + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/operatortest" |
| 11 | +) |
| 12 | + |
| 13 | +// test unmarshalling of values into config struct |
| 14 | +func TestUnmarshal(t *testing.T) { |
| 15 | + operatortest.ConfigUnmarshalTests{ |
| 16 | + DefaultConfig: NewConfig(), |
| 17 | + TestsFile: filepath.Join(".", "testdata", "config.yaml"), |
| 18 | + Tests: []operatortest.ConfigUnmarshalTest{ |
| 19 | + { |
| 20 | + Name: "strip_ansi_escape_codes_body", |
| 21 | + Expect: func() *Config { |
| 22 | + cfg := NewConfig() |
| 23 | + cfg.Field = entry.NewBodyField("nested") |
| 24 | + return cfg |
| 25 | + }(), |
| 26 | + }, |
| 27 | + { |
| 28 | + Name: "strip_ansi_escape_codes_single_attribute", |
| 29 | + Expect: func() *Config { |
| 30 | + cfg := NewConfig() |
| 31 | + cfg.Field = entry.NewAttributeField("key") |
| 32 | + return cfg |
| 33 | + }(), |
| 34 | + }, |
| 35 | + { |
| 36 | + Name: "strip_ansi_escape_codes_single_resource", |
| 37 | + Expect: func() *Config { |
| 38 | + cfg := NewConfig() |
| 39 | + cfg.Field = entry.NewResourceField("key") |
| 40 | + return cfg |
| 41 | + }(), |
| 42 | + }, |
| 43 | + { |
| 44 | + Name: "strip_ansi_escape_codes_nested_body", |
| 45 | + Expect: func() *Config { |
| 46 | + cfg := NewConfig() |
| 47 | + cfg.Field = entry.NewBodyField("one", "two") |
| 48 | + return cfg |
| 49 | + }(), |
| 50 | + }, |
| 51 | + { |
| 52 | + Name: "strip_ansi_escape_codes_nested_attribute", |
| 53 | + Expect: func() *Config { |
| 54 | + cfg := NewConfig() |
| 55 | + cfg.Field = entry.NewAttributeField("one", "two") |
| 56 | + return cfg |
| 57 | + }(), |
| 58 | + }, |
| 59 | + { |
| 60 | + Name: "strip_ansi_escape_codes_nested_resource", |
| 61 | + Expect: func() *Config { |
| 62 | + cfg := NewConfig() |
| 63 | + cfg.Field = entry.NewResourceField("one", "two") |
| 64 | + return cfg |
| 65 | + }(), |
| 66 | + }, |
| 67 | + }, |
| 68 | + }.Run(t) |
| 69 | +} |
0 commit comments