tetragon icon indicating copy to clipboard operation
tetragon copied to clipboard

Inappropriate uses of assert.NoError?

Open knrc opened this issue 1 year ago • 2 comments

While completing a simple PR as part of the KubeCon contribfest I hit an issue where one test was causing a panic.

I tracked this down to the use of assert.NoError(t, err) for checking errors, but instead of being used as a guard for the subsequent test code it continued as if the error did not occur and dereferenced a nil. It looks as if this may occur often within the project tests.

knrc avatar Nov 15 '24 18:11 knrc

Just wanna share the experience in cilium/cilium. I think the value of assert.NoError is to gather all the outputs/failures at once, so that developer can fix in one shot. However, it requires a careful thinking to make sure there is no side effect or misleading or even panic, hence in cilium/cilium most of assert.* is changed to require.* recently in main branch.

sayboras avatar Nov 16 '24 00:11 sayboras

Yap, agreed: we should change those into require.NoError.

kkourt avatar Dec 03 '24 07:12 kkourt

It was fixed by https://github.com/cilium/tetragon/pull/3769.

mtardy avatar Jul 16 '25 15:07 mtardy