Skip to content
Snippets Groups Projects
Verified Commit e9179637 authored by Mikhail Mazurskiy's avatar Mikhail Mazurskiy
Browse files

Fix flaky test

=== RUN   TestMakeGitLabRequest_HappyPath
    controller.go:137: missing call(s) to *mock_gitlab_access.MockGitlabAccess_MakeRequestClient.Send(equals trailer:{} with 1 option(s)) cmd/agentk/agentkapp/api_test.go:329
    controller.go:137: missing call(s) to *mock_gitlab_access.MockGitlabAccess_MakeRequestClient.CloseSend() cmd/agentk/agentkapp/api_test.go:332
    controller.go:137: aborting test due to missing call(s)
parent 6452a9dd
No related branches found
No related tags found
1 merge request!495Misc cleanups
......@@ -329,7 +329,19 @@ func mockSendStream(t *testing.T, client *mock_gitlab_access.MockGitlabAccess_Ma
Send(matcher.ProtoEq(t, msg))
res = append(res, call)
}
res = append(res, client.EXPECT().CloseSend())
streamDone := make(chan struct{})
res = append(res, client.EXPECT().
CloseSend().
Do(func() {
close(streamDone)
}))
t.Cleanup(func() {
// The sending is done concurrently and test can finish earlier than the sending goroutine is done sending.
// In that case there will be a missing expected invocation. Wait for it to finish before proceeding.
// t.Cleanup() processes added functions in LIFO order, so this one should be executed before the validation
// function (added by gomock.NewController()).
<-streamDone
})
return res
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment