MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestErrorfAs

Function TestErrorfAs

internal/redact/redact_test.go:154–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

152}
153
154func TestErrorfAs(t *testing.T) {
155 wrapped := &customError{
156 msg: "sensitive",
157 value: "value",
158 }
159 err := Errorf("error: %w", wrapped)
160 checkUnredactedError(t, err, "error: sensitive")
161 checkRedactedError(t, err, "error: <redacted *redact.customError>")
162
163 var unwrapped *customError
164 if !errors.As(err, &unwrapped) {
165 t.Error("got errors.As(err, unwrapped) == false")
166 }
167 if unwrapped.value != wrapped.value {
168 t.Error("got unwrapped.value != wrapped.value")
169 }
170
171 var unwrappedRedacted *customError
172 if !errors.As(Error(err), &unwrappedRedacted) {
173 t.Error("got errors.As(Error(err), &unwrappedRedacted) == false")
174 }
175 if unwrappedRedacted.value != wrapped.value {
176 t.Error("got unwrappedRedacted.value != wrapped.value")
177 }
178}
179
180func TestErrorfRedactableArg(t *testing.T) {
181 err := Errorf("%d", redactableInt(123))

Callers

nothing calls this directly

Calls 5

ErrorfFunction · 0.85
checkUnredactedErrorFunction · 0.85
checkRedactedErrorFunction · 0.85
ErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected