Skip to content

Commit cd27384

Browse files
committed
test: fix race condition
1 parent acbaca3 commit cd27384

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

go/discovery_kit_sdk/caching_discovery_target_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/steadybit/discovery-kit/go/discovery_kit_api"
1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/mock"
13+
"slices"
1314
"testing"
1415
"time"
1516
)
@@ -281,7 +282,10 @@ func Test_target_string_interning_concurrent_modification(t *testing.T) {
281282
}
282283

283284
discovery.On("DiscoverTargets", mock.Anything).Unset()
284-
discovery.On("DiscoverTargets", ctx).Return(targets, nil)
285+
call := discovery.On("DiscoverTargets", ctx)
286+
call.RunFn = func(args mock.Arguments) {
287+
call.Return(slices.Clone(targets))
288+
}
285289

286290
go func() {
287291
defer func() {

0 commit comments

Comments
 (0)