From 80374c6d93d6618dc957e09c24e821da9b69817e Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Fri, 21 Feb 2025 09:50:39 -0500 Subject: [PATCH] Move nonblocking AddSnowflake out of goroutine in sqs test This fixes a race condition in tests where sometimes snowflake matching happens before enough snowflakes get added to the heap. --- broker/sqs_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/broker/sqs_test.go b/broker/sqs_test.go index ab2e761..0f5e790 100644 --- a/broker/sqs_test.go +++ b/broker/sqs_test.go @@ -140,8 +140,8 @@ func TestSQS(t *testing.T) { mockSQSClient.EXPECT().ReceiveMessage(sqsHandlerContext, &sqsReceiveMessageInput).AnyTimes().DoAndReturn( func(ctx context.Context, input *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) { + snowflake := ipcCtx.AddSnowflake("fake", "", NATUnrestricted, 0) go func(c C) { - snowflake := ipcCtx.AddSnowflake("fake", "", NATUnrestricted, 0) <-snowflake.offerChannel snowflake.answerChannel <- "fake answer" }(c)