Improve error handling in Connect gateway integration test#19145
Improve error handling in Connect gateway integration test#19145
Conversation
mockTSHDEventsClient will most likely be called outside of the test goroutine, so we shouldn't use require.NoError there. helpers.SetupUserCreds returns an error which I did not inspect. The linter didn't warn me about it for some reason.
espadolini
left a comment
There was a problem hiding this comment.
Is this better than using assert.NoError instead?
|
I suppose If I understand correctly, That is, I'm not sure if I should do this: err = helpers.SetupUserCreds(c.tc, c.pack.Root.Cluster.Config.Proxy.SSHAddr.Addr, *creds)
assert.NoError(c.t, err)
return &api.ReloginResponse{}, nilor err = helpers.SetupUserCreds(c.tc, c.pack.Root.Cluster.Config.Proxy.SSHAddr.Addr, *creds)
if !assert.NoError(c.t, err) {
return nil, trace.Wrap(err)
}
return &api.ReloginResponse{}, nilFrom what I see, in the project we seem to use the first approach. |
|
This also reminds me that asserting something without failing the test immediately would also be helpful when checking the number of calls to the mock. I had a test that was failing on this check: teleport/integration/proxy/teleterm_test.go Lines 155 to 158 in b2e1807 but if these two were performed as assertions before that teleport/integration/proxy/teleterm_test.go Lines 168 to 171 in b2e1807 Would that be an okay approach or would you rather say it's misusing the assert package? |
|
@espadolini Could you offer an advice or an opinion on using |
|
I don't know if mocks should have access to the |
|
@ravicious See the table below for backport results.
|
A few small things that I missed when I added this test in #17950.
mockTSHDEventsClient will most likely be called outside of the test goroutine, so we shouldn't use require.NoError there.
helpers.SetupUserCreds returns an error which I did not inspect. The linter didn't warn me about it for some reason.