Skip to content

Commit

Permalink
[configopaque, confmap] Change yaml test by confmap test (#9442)
Browse files Browse the repository at this point in the history
**Description:** 

- Remove yaml test from configopaque
- Add test in confmap testing `configopaque`

**Link to tracking Issue:** From discussion on #9427
  • Loading branch information
mx-psi authored Feb 1, 2024
1 parent fc81583 commit cc7265d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
10 changes: 10 additions & 0 deletions config/configopaque/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ go 1.20

require (
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/confmap v0.93.0
go.uber.org/goleak v1.3.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.0.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

replace go.opentelemetry.io/collector/confmap => ../../confmap
14 changes: 14 additions & 0 deletions config/configopaque/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions config/configopaque/opaque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"

"go.opentelemetry.io/collector/confmap"
)

var _ encoding.TextMarshaler = String("")
Expand Down Expand Up @@ -47,10 +48,11 @@ func TestStringJSON(t *testing.T) {
assert.Equal(t, `{"opaque":"[REDACTED]","plain":"plain"}`, string(bytes))
}

func TestStringYAML(t *testing.T) {
bytes, err := yaml.Marshal(example)
require.NoError(t, err)
assert.Equal(t, "opaque: '[REDACTED]'\nplain: plain\n", string(bytes))
func TestConfMapMarshalConfigOpaque(t *testing.T) {
conf := confmap.New()
assert.NoError(t, conf.Marshal(example))
assert.Equal(t, "[REDACTED]", conf.Get("opaque"))
assert.Equal(t, "plain", conf.Get("plain"))
}

func TestStringFmt(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions config/configtls/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ require (
)

replace go.opentelemetry.io/collector/config/configopaque => ../configopaque

replace go.opentelemetry.io/collector/confmap => ../../confmap
7 changes: 7 additions & 0 deletions config/configtls/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions confmap/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

retract (
Expand Down
13 changes: 2 additions & 11 deletions confmap/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc7265d

Please sign in to comment.