Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][config/configopaque] Move implementation checks to test files #9430

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions config/configopaque/opaque.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package configopaque // import "go.opentelemetry.io/collector/config/configopaque"

import (
"encoding"
"fmt"
)

Expand All @@ -14,31 +13,23 @@ type String string

const maskedString = "[REDACTED]"

var _ encoding.TextMarshaler = String("")

// MarshalText marshals the string as `[REDACTED]`.
func (s String) MarshalText() ([]byte, error) {
return []byte(maskedString), nil
}

var _ fmt.Stringer = String("")

// String formats the string as `[REDACTED]`.
// This is used for the %s and %q verbs.
func (s String) String() string {
return maskedString
}

var _ fmt.GoStringer = String("")

// GoString formats the string as `[REDACTED]`.
// This is used for the %#v verb.
func (s String) GoString() string {
return fmt.Sprintf("%#v", maskedString)
}

var _ encoding.BinaryMarshaler = String("")

// MarshalBinary marshals the string `[REDACTED]` as []byte.
func (s String) MarshalBinary() (text []byte, err error) {
return []byte(maskedString), nil
Expand Down
9 changes: 9 additions & 0 deletions config/configopaque/opaque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package configopaque // import "go.opentelemetry.io/collector/config/configopaque"

import (
"encoding"
"encoding/json"
"fmt"
"testing"
Expand All @@ -13,6 +14,14 @@ import (
"gopkg.in/yaml.v3"
)

var _ encoding.TextMarshaler = String("")

var _ fmt.Stringer = String("")

var _ fmt.GoStringer = String("")

var _ encoding.BinaryMarshaler = String("")

func TestStringMarshalText(t *testing.T) {
examples := []String{"opaque", "s", "veryveryveryveryveryveryveryveryveryverylong"}
for _, example := range examples {
Expand Down
Loading