diff --git a/controller/northbound/server/auth_test.go b/controller/northbound/server/auth_test.go index 3f421a5a871f107bf05a8e0396a41d5010aa0af4..409b19e3e8a1295ecdb545c1b407568234981858 100644 --- a/controller/northbound/server/auth_test.go +++ b/controller/northbound/server/auth_test.go @@ -1,7 +1,9 @@ package server import ( + "bytes" "context" + "log" "reflect" "testing" @@ -150,6 +152,7 @@ func TestAuth_CreateUsers(t *testing.T) { } func TestAuth_GetUser(t *testing.T) { + patchLogger(t) type args struct { ctx context.Context request *apb.GetUserRequest @@ -829,3 +832,16 @@ func createTestRoles() error { return nil } + +func patchLogger(t *testing.T) { + orig := log.Writer() + buf := new(bytes.Buffer) + log.SetOutput(buf) + + t.Cleanup(func() { + // optionally check t.Failed here if you only want to print logs on failure + + t.Log(buf.String()) + log.SetOutput(orig) + }) +}