Skip to content

Commit

Permalink
[chore] move opaque confmap test (open-telemetry#10358)
Browse files Browse the repository at this point in the history
This removes the dependency on confmap for tests in configopaque

---------

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored Jun 6, 2024
1 parent 6888f8f commit a6ace53
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 56 deletions.
11 changes: 0 additions & 11 deletions config/configopaque/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,14 @@ go 1.21.0

require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/confmap v0.102.1
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/go-viper/mapstructure/v2 v2.0.0-alpha.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.1.1 // indirect
github.com/kr/pretty v0.3.1 // 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
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

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

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

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

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

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

var _ encoding.TextMarshaler = String("")
Expand Down Expand Up @@ -48,13 +46,6 @@ func TestStringJSON(t *testing.T) {
assert.Equal(t, `{"opaque":"[REDACTED]","plain":"plain"}`, 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) {
examples := []String{"opaque", "s", "veryveryveryveryveryveryveryveryveryverylong"}
verbs := []string{"%s", "%q", "%v", "%#v", "%+v", "%x"}
Expand Down
2 changes: 0 additions & 2 deletions config/configtls/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ require (
)

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

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

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

4 changes: 2 additions & 2 deletions internal/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ require (
go.opentelemetry.io/collector/component v0.102.1
go.opentelemetry.io/collector/config/configgrpc v0.102.1
go.opentelemetry.io/collector/config/confighttp v0.102.1
go.opentelemetry.io/collector/config/configopaque v1.9.0
go.opentelemetry.io/collector/config/configretry v0.102.1
go.opentelemetry.io/collector/config/configtls v0.102.1
go.opentelemetry.io/collector/confmap v0.102.1
go.opentelemetry.io/collector/consumer v0.102.1
go.opentelemetry.io/collector/exporter v0.102.1
go.opentelemetry.io/collector/exporter/otlpexporter v0.102.0
Expand Down Expand Up @@ -55,10 +57,8 @@ require (
go.opentelemetry.io/collector/config/configauth v0.102.1 // indirect
go.opentelemetry.io/collector/config/configcompression v1.9.0 // indirect
go.opentelemetry.io/collector/config/confignet v0.102.1 // indirect
go.opentelemetry.io/collector/config/configopaque v1.9.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.102.1 // indirect
go.opentelemetry.io/collector/config/internal v0.102.1 // indirect
go.opentelemetry.io/collector/confmap v0.102.1 // indirect
go.opentelemetry.io/collector/extension v0.102.1 // indirect
go.opentelemetry.io/collector/extension/auth v0.102.1 // indirect
go.opentelemetry.io/collector/featuregate v1.9.0 // indirect
Expand Down
30 changes: 30 additions & 0 deletions internal/e2e/opaque_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package e2e

import (
"testing"

"github.com/stretchr/testify/assert"

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

type TestStruct struct {
Opaque configopaque.String `json:"opaque" yaml:"opaque"`
Plain string `json:"plain" yaml:"plain"`
}

var example = TestStruct{
Opaque: "opaque",
Plain: "plain",
}

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"))
}

0 comments on commit a6ace53

Please sign in to comment.