Maintenance: Fix test data race
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -53,11 +54,14 @@ func Test_resolveRepeat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
const host = "blabla"
|
const host = "blabla"
|
||||||
i := 0
|
i := 0
|
||||||
|
mutex := &sync.Mutex{}
|
||||||
lookupIP := func(ctx context.Context, argHost string) (
|
lookupIP := func(ctx context.Context, argHost string) (
|
||||||
ips []net.IP, err error) {
|
ips []net.IP, err error) {
|
||||||
assert.Equal(t, host, argHost)
|
assert.Equal(t, host, argHost)
|
||||||
|
mutex.Lock()
|
||||||
result := testCase.lookupIPResult[i]
|
result := testCase.lookupIPResult[i]
|
||||||
i++
|
i++
|
||||||
|
mutex.Unlock()
|
||||||
return result, testCase.err
|
return result, testCase.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user