From 7087fe6c459b54df62134b9f1243b4525695fa1f Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Wed, 26 Apr 2023 23:20:42 -0400 Subject: [PATCH] Better waiting for upload tests to finish --- upload/uploader_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/upload/uploader_test.go b/upload/uploader_test.go index 75008373..1fe8915c 100644 --- a/upload/uploader_test.go +++ b/upload/uploader_test.go @@ -49,6 +49,7 @@ func Test_UploaderSingleUpload(t *testing.T) { go uploader.Start(ctx, nil) wg.Wait() cancel() + <-ctx.Done() if exp, got := string(uploadedData), "my upload data"; exp != got { t.Errorf("expected uploadedData to be %s, got %s", exp, got) @@ -92,6 +93,7 @@ func Test_UploaderDoubleUpload(t *testing.T) { go uploader.Start(ctx, nil) wg.Wait() cancel() + <-ctx.Done() if exp, got := string(uploadedData), "my upload data"; exp != got { t.Errorf("expected uploadedData to be %s, got %s", exp, got) @@ -141,6 +143,7 @@ func Test_UploaderFailThenOK(t *testing.T) { go uploader.Start(ctx, nil) wg.Wait() cancel() + <-ctx.Done() if exp, got := string(uploadedData), "my upload data"; exp != got { t.Errorf("expected uploadedData to be %s, got %s", exp, got) @@ -188,6 +191,7 @@ func Test_UploaderOKThenFail(t *testing.T) { go uploader.Start(ctx, nil) wg.Wait() cancel() + <-ctx.Done() if exp, got := string(uploadedData), "my upload data"; exp != got { t.Errorf("expected uploadedData to be %s, got %s", exp, got) @@ -210,6 +214,7 @@ func Test_UploaderContextCancellation(t *testing.T) { go uploader.Start(ctx, nil) <-ctx.Done() cancel() + <-ctx.Done() if exp, got := int32(0), atomic.LoadInt32(&uploadCount); exp != got { t.Errorf("expected uploadCount to be %d, got %d", exp, got)