From 42d828f1be0202b926357cb2b392c979b6af1724 Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Fri, 5 Jul 2024 00:21:32 +0200 Subject: [PATCH] Improve TestProjectServiceServer_Load_ClientConnClosed --- .../project/projectservice/project_service_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/project/projectservice/project_service_test.go b/internal/project/projectservice/project_service_test.go index 9a8edeb37..351076776 100644 --- a/internal/project/projectservice/project_service_test.go +++ b/internal/project/projectservice/project_service_test.go @@ -77,7 +77,7 @@ func TestProjectServiceServer_Load(t *testing.T) { }) } -func TestProjectServiceServer_Load_ErrorWhileSending(t *testing.T) { +func TestProjectServiceServer_Load_ClientConnClosed(t *testing.T) { t.Parallel() temp := t.TempDir() @@ -98,8 +98,10 @@ func TestProjectServiceServer_Load_ErrorWhileSending(t *testing.T) { loadClient, err := client.Load(context.Background(), req) require.NoError(t, err) - err = clientConn.Close() - require.NoError(t, err) + errc := make(chan error, 1) + go func() { + errc <- clientConn.Close() + }() for { _, err := loadClient.Recv() @@ -108,6 +110,8 @@ func TestProjectServiceServer_Load_ErrorWhileSending(t *testing.T) { break } } + + require.NoError(t, <-errc) } func collectLoadEventTypes(client projectv1.ProjectService_LoadClient) ([]projectv1.LoadEventType, error) {