From 38b944a2e5fc732aa8541b48406faa9d6b2ba966 Mon Sep 17 00:00:00 2001 From: tmdiep Date: Fri, 5 Feb 2021 06:18:02 +1100 Subject: [PATCH] test(pubsublite): fix flaky TestAssignerHandlePartitionFailure (#3671) Checks only the final error to ensure the test is deterministic. Fixes https://github.com/googleapis/google-cloud-go/issues/3667. --- pubsublite/internal/wire/assigner_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pubsublite/internal/wire/assigner_test.go b/pubsublite/internal/wire/assigner_test.go index 4e3c15ba5291..4f33a3e15987 100644 --- a/pubsublite/internal/wire/assigner_test.go +++ b/pubsublite/internal/wire/assigner_test.go @@ -199,13 +199,10 @@ func TestAssignerHandlePartitionFailure(t *testing.T) { wantErr := errors.New("subscriber shutting down") asn.SetReceiveError(wantErr) - if gotErr := asn.StartError(); gotErr != nil { - t.Errorf("Start() got err: (%v)", gotErr) + if gotErr := asn.FinalError(); !test.ErrorEqual(gotErr, wantErr) { + t.Errorf("Final err: (%v), want: (%v)", gotErr, wantErr) } if got, want := asn.NextPartitions(), []int{1, 2}; !testutil.Equal(got, want) { t.Errorf("Partition assignments: got %v, want %v", got, want) } - if gotErr := asn.FinalError(); !test.ErrorEqual(gotErr, wantErr) { - t.Errorf("Final err: (%v), want: (%v)", gotErr, wantErr) - } }