Skip to content

Commit a7d27dc

Browse files
committed
race fix
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent 49f6f76 commit a7d27dc

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

token/services/identity/membership/lm_discovery_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ func TestLocalMembership_Notifier(t *testing.T) {
240240

241241
iss.IteratorConfigurationsReturns(&mock.IdentityConfigurationIterator{}, nil)
242242

243+
var mu sync.Mutex
243244
var subCallback fscdriver.TriggerCallback
244245
notifier.SubscribeStub = func(callback fscdriver.TriggerCallback) error {
246+
mu.Lock()
247+
defer mu.Unlock()
245248
subCallback = callback
246249

247250
return nil
@@ -251,14 +254,20 @@ func TestLocalMembership_Notifier(t *testing.T) {
251254
require.NoError(t, err)
252255

253256
assert.Eventually(t, func() bool {
257+
mu.Lock()
258+
defer mu.Unlock()
259+
254260
return subCallback != nil
255261
}, 2*time.Second, 100*time.Millisecond)
256262

257263
newConfig := idriver.IdentityConfiguration{ID: "new", URL: "/tmp/new", Type: "testType"}
258264
iss.GetConfigurationReturns(&newConfig, nil)
259265

260266
// Simulate notification
261-
subCallback(idriver.Insert, map[idriver.ColumnKey]string{
267+
mu.Lock()
268+
callback := subCallback
269+
mu.Unlock()
270+
callback(idriver.Insert, map[idriver.ColumnKey]string{
262271
"id": "new",
263272
"type": "testType",
264273
"url": "/tmp/new",

0 commit comments

Comments
 (0)