fix: resolve race condition in TestContainerStore_die (#4591)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Amir Raminfar
2026-04-05 15:47:54 -07:00
committed by GitHub
parent 32fac82635
commit 5abda9f224
@@ -81,10 +81,12 @@ func TestContainerStore_die(t *testing.T) {
},
}, nil)
ready := make(chan struct{})
client.On("ContainerEvents", mock.Anything, mock.AnythingOfType("chan<- container.ContainerEvent")).Return(nil).
Run(func(args mock.Arguments) {
ctx := args.Get(0).(context.Context)
events := args.Get(1).(chan<- ContainerEvent)
<-ready
events <- ContainerEvent{
Name: "die",
ActorID: "1234",
@@ -110,6 +112,7 @@ func TestContainerStore_die(t *testing.T) {
// Wait until we get the event
events := make(chan ContainerEvent)
store.SubscribeEvents(t.Context(), events)
close(ready)
<-events
containers, _ := store.ListContainers(ContainerLabels{})