From 2c9d4857e5c26830f9057003679c05a86675a2a1 Mon Sep 17 00:00:00 2001 From: Fabian Seidl <fabian.b.seidl@stud.h-da.de> Date: Fri, 29 Apr 2022 15:36:06 +0200 Subject: [PATCH] workaround for false output of passing getUser test --- controller/northbound/server/auth_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/controller/northbound/server/auth_test.go b/controller/northbound/server/auth_test.go index 3f421a5a8..409b19e3e 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) + }) +} -- GitLab