Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: WashingtonKK <[email protected]>
  • Loading branch information
WashingtonKK committed Aug 22, 2024
1 parent 6266312 commit f819902
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion manager/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ func TestRun(t *testing.T) {
}

func TestStop(t *testing.T) {
vmf := new(mocks.Provider)
vmMock := new(mocks.VM)
vmf.On("Execute", mock.Anything, mock.Anything, mock.Anything).Return(vmMock)

tests := []struct {
name string
computationID string
Expand Down Expand Up @@ -156,8 +160,12 @@ func TestStop(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
logger := slog.Default()
eventsChan := make(chan *manager.ClientStreamMessage, 10)
ms := &managerService{
vms: make(map[string]vm.VM),
logger: logger,
vms: make(map[string]vm.VM),
eventsChan: eventsChan,
}
vmMock := new(mocks.VM)

Expand All @@ -180,6 +188,11 @@ func TestStop(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, ms.vms, 0)
}

// Clear the events channel
for len(eventsChan) > 0 {
<-eventsChan
}
})
}
}
Expand Down

0 comments on commit f819902

Please sign in to comment.