@@ -239,6 +239,22 @@ func TestSafeMessageDebug(t *testing.T) {
239
239
formatAndArgs : []any {true , false },
240
240
wantSafeString : "prefix: adapter.startAuthentication{}, true false" ,
241
241
},
242
+ "startAuthentication_message_with_prefix_and_multiple_formatted_values_suffix" : {
243
+ msg : startAuthentication {},
244
+ prefix : "prefix" ,
245
+ formatAndArgs : []any {
246
+ newPasswordCheck {password : "password!" },
247
+ UILayoutReceived {& authd.UILayout {Type : "Foo" }},
248
+ authModesReceived {
249
+ authModes : []* authd.GAMResponse_AuthenticationMode {
250
+ {Id : "id1" , Label : "Label1" },
251
+ {Id : "id2" , Label : "Label2" },
252
+ },
253
+ },
254
+ },
255
+ wantDebugString : `prefix: adapter.startAuthentication{}, adapter.newPasswordCheck{ctx:context.Context(nil), password:"password!"} adapter.UILayoutReceived{layouts:*authd.UILayout{{"type":"Foo"}}} adapter.authModesReceived{authModes:[]*authd.GAMResponse_AuthenticationMode{[{"id":"id1","label":"Label1"},{"id":"id2","label":"Label2"}]}}` ,
256
+ wantSafeString : `prefix: adapter.startAuthentication{}, adapter.newPasswordCheck{ctx:context.Context(nil), password:"***********"} adapter.UILayoutReceived{layouts:*authd.UILayout{{"type":"Foo"}}} adapter.authModesReceived{authModes:[]*authd.GAMResponse_AuthenticationMode{[{"id":"id1","label":"Label1"},{"id":"id2","label":"Label2"}]}}` ,
257
+ },
242
258
"startAuthentication_message_with_prefix_and_single_string_suffix" : {
243
259
msg : startAuthentication {},
244
260
prefix : "prefix" ,
@@ -329,11 +345,12 @@ func TestSafeMessageDebug(t *testing.T) {
329
345
handlerCalled := false
330
346
wantCtx := context .Background ()
331
347
log .SetLevelHandler (log .DebugLevel , func (ctx context.Context , l log.Level , format string , args ... interface {}) {
332
- t .Logf (format , args ... )
348
+ t .Logf ("Format: %q" , format )
349
+ t .Log (append ([]any {"Args:" }, args ... )... )
333
350
handlerCalled = true
334
351
require .Equal (t , wantCtx , ctx , "Context should match expected" )
335
352
require .Equal (t , tc .wantSafeString , fmt .Sprintf (format , args ... ),
336
- "Format should match" )
353
+ "Format for safe usage should match" )
337
354
})
338
355
339
356
initialLogLevel := log .GetLevel ()
@@ -363,11 +380,11 @@ func TestSafeMessageDebug(t *testing.T) {
363
380
log .SetLevelHandler (log .DebugLevel , func (ctx context.Context , l log.Level , format string , args ... interface {}) {
364
381
t .Logf (format , args ... )
365
382
handlerCalled = true
366
- t .Logf ("Called with %q" , format )
367
- t .Logf ( "Atgs are %#v" , args )
383
+ t .Logf ("Format: %q" , format )
384
+ t .Log ( append ([] any { "Args:" } , args ... ) ... )
368
385
require .Equal (t , wantCtx , ctx , "Context should match expected" )
369
386
require .Equal (t , tc .wantDebugString , fmt .Sprintf (format , args ... ),
370
- "Format should match" )
387
+ "Format for debug usage should match" )
371
388
})
372
389
373
390
initialLogLevel := log .GetLevel ()
0 commit comments