MCPcopy
hub / github.com/docker/docker-agent / TestWrapErrorsFlagsEscapedPercentW

Function TestWrapErrorsFlagsEscapedPercentW

lint/wrap_errors_test.go:33–42  ·  view source on GitHub ↗

An escaped percent followed by the letter w ("%%w") is a literal, not a wrapping verb: a real unwrapped error in the same call must still be flagged.

(t *testing.T)

Source from the content-addressed store, hash-verified

31// An escaped percent followed by the letter w ("%%w") is a literal, not a
32// wrapping verb: a real unwrapped error in the same call must still be flagged.
33func TestWrapErrorsFlagsEscapedPercentW(t *testing.T) {
34 t.Parallel()
35 src := `package p
36import "fmt"
37func f(err error) error { return fmt.Errorf("done 50%%w: %v", err) }
38`
39 offenses := coptest.RunTyped(t, WrapErrors, src)
40 require.Len(t, offenses, 1)
41 assert.Equal(t, "Lint/WrapErrors", offenses[0].CopName)
42}
43
44func TestWrapErrorsIgnoresNonErrorArgs(t *testing.T) {
45 t.Parallel()

Callers

nothing calls this directly

Calls 1

LenMethod · 0.65

Tested by

no test coverage detected