Files
bd98af2b83 fix(deps): update module github.com/golangci/golangci-lint to v1.62.0 (#11644)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/golangci/golangci-lint](https://redirect.github.com/golangci/golangci-lint)
| `v1.61.0` -> `v1.62.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolangci%2fgolangci-lint/v1.62.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolangci%2fgolangci-lint/v1.62.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolangci%2fgolangci-lint/v1.61.0/v1.62.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolangci%2fgolangci-lint/v1.61.0/v1.62.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>golangci/golangci-lint
(github.com/golangci/golangci-lint)</summary>

###
[`v1.62.0`](https://redirect.github.com/golangci/golangci-lint/compare/v1.61.0...v1.62.0)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.61.0...v1.62.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-collector).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS45LjUiLCJ1cGRhdGVkSW5WZXIiOiIzOS45LjUiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyIsInJlbm92YXRlYm90Il19-->

---------

Signed-off-by: Bogdan Drutu <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: opentelemetrybot <[email protected]>
Co-authored-by: Yang Song <[email protected]>
Co-authored-by: Bogdan Drutu <[email protected]>
Co-authored-by: Yang Song <[email protected]>
2024-11-13 12:15:45 -08:00

95 lines
2.4 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package configopaque // import "go.opentelemetry.io/collector/config/configopaque"
import (
"encoding"
"encoding/hex"
"encoding/json"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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 {
opaque, err := example.MarshalText()
require.NoError(t, err)
assert.Equal(t, maskedString, string(opaque))
}
}
type TestStruct struct {
Opaque String `json:"opaque" yaml:"opaque"`
Plain string `json:"plain" yaml:"plain"`
}
var example = TestStruct{
Opaque: "opaque",
Plain: "plain",
}
func TestStringJSON(t *testing.T) {
bytes, err := json.Marshal(example)
require.NoError(t, err)
assert.JSONEq(t, `{"opaque":"[REDACTED]","plain":"plain"}`, string(bytes))
}
func TestStringFmt(t *testing.T) {
examples := []String{"opaque", "s", "veryveryveryveryveryveryveryveryveryverylong"}
verbs := []string{"%s", "%q", "%v", "%#v", "%+v", "%x"}
for _, example := range examples {
for _, verb := range verbs {
t.Run(fmt.Sprintf("%s/%s", string(example), verb), func(t *testing.T) {
assert.Equal(t,
fmt.Sprintf(verb, maskedString),
fmt.Sprintf(verb, example),
)
})
}
for _, verb := range verbs {
t.Run(fmt.Sprintf("string(%s)/%s", string(example), verb), func(t *testing.T) {
// converting to a string allows to output as an unredacted string still:
var expected string
switch verb {
case "%s", "%v", "%+v":
expected = string(example)
case "%q", "%#v":
expected = "\"" + string(example) + "\""
case "%x":
expected = hex.EncodeToString([]byte(example))
default:
t.Errorf("unexpected verb %q", verb)
}
assert.Equal(t,
expected,
fmt.Sprintf(verb, string(example)),
)
})
}
}
}
func TestStringMarshalBinary(t *testing.T) {
examples := []String{"opaque", "s", "veryveryveryveryveryveryveryveryveryverylong"}
for _, example := range examples {
opaque, err := example.MarshalBinary()
require.NoError(t, err)
assert.Equal(t, []byte("[REDACTED]"), opaque)
}
}