From 1abb716bb6fbd37b95b2de9a884529ce9933dfd7 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Wed, 6 Jan 2021 06:09:19 +0000 Subject: [PATCH] Maintenance: Fix test data race --- internal/updater/resolver_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/updater/resolver_test.go b/internal/updater/resolver_test.go index bd3d8524..13fa6b5a 100644 --- a/internal/updater/resolver_test.go +++ b/internal/updater/resolver_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net" + "sync" "testing" "github.com/stretchr/testify/assert" @@ -53,11 +54,14 @@ func Test_resolveRepeat(t *testing.T) { } const host = "blabla" i := 0 + mutex := &sync.Mutex{} lookupIP := func(ctx context.Context, argHost string) ( ips []net.IP, err error) { assert.Equal(t, host, argHost) + mutex.Lock() result := testCase.lookupIPResult[i] i++ + mutex.Unlock() return result, testCase.err }