Maintenance: Fix test data race

This commit is contained in:
Quentin McGaw
2021-01-06 06:09:19 +00:00
parent 3f012dd7a3
commit 1abb716bb6

View File

@@ -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
}