Skip to content

Commit 4b14959

Browse files
committed
protosanitizer: test +v conversion
Sometimes "%+v" was used to print a message although it produces the same output as "%v" and "%s" for gRPC messages because they implement fmt.Stringer. It's worthwhile having a test that ensures that wrapping the message with StripSecrets and printing with "+v" still works.
1 parent 0f63044 commit 4b14959

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

protosanitizer/protosanitizer_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ func TestStripSecrets(t *testing.T) {
210210
stripped = StripSecrets(c.original)
211211
}
212212
if assert.Equal(t, c.stripped, fmt.Sprintf("%s", stripped), "unexpected result for fmt s of %s", c.original) {
213-
assert.Equal(t, c.stripped, fmt.Sprintf("%v", stripped), "unexpected result for fmt v of %s", c.original)
213+
if assert.Equal(t, c.stripped, fmt.Sprintf("%v", stripped), "unexpected result for fmt v of %s", c.original) {
214+
assert.Equal(t, c.stripped, fmt.Sprintf("%+v", stripped), "unexpected result for fmt +v of %s", c.original)
215+
}
214216
}
215217
assert.Equal(t, before, fmt.Sprint(c.original), "original value modified")
216218
}

0 commit comments

Comments
 (0)