lint/deep-exit: avoid log.Fatal (#3367)

* lint/deep-exit: don't fail on invalid alert
* lint/deep-exit: kinesis_test.go
* lint/deep-exit: watcher_test.go
* lint/deep-exit: parsing_test.go
* lint/deep-exit: client_test.go
This commit is contained in:
mmetc 2024-12-18 16:43:19 +01:00 committed by GitHub
parent 2c95a24f69
commit ecf34c2fa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 87 additions and 126 deletions

View file

@ -15,13 +15,12 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/models"
)
func resetTestTomb(testTomb *tomb.Tomb, pw *PluginWatcher) {
func resetTestTomb(t *testing.T, testTomb *tomb.Tomb, pw *PluginWatcher) {
testTomb.Kill(nil)
<-pw.PluginEvents
if err := testTomb.Wait(); err != nil {
log.Fatal(err)
}
err := testTomb.Wait()
require.NoError(t, err)
}
func resetWatcherAlertCounter(pw *PluginWatcher) {
@ -72,7 +71,7 @@ func TestPluginWatcherInterval(t *testing.T) {
err := listenChannelWithTimeout(ct, pw.PluginEvents)
cstest.RequireErrorContains(t, err, "context deadline exceeded")
resetTestTomb(&testTomb, &pw)
resetTestTomb(t, &testTomb, &pw)
testTomb = tomb.Tomb{}
pw.Start(&testTomb)
@ -81,7 +80,7 @@ func TestPluginWatcherInterval(t *testing.T) {
err = listenChannelWithTimeout(ct, pw.PluginEvents)
require.NoError(t, err)
resetTestTomb(&testTomb, &pw)
resetTestTomb(t, &testTomb, &pw)
// This is to avoid the int complaining
}
@ -130,5 +129,5 @@ func TestPluginAlertCountWatcher(t *testing.T) {
err = listenChannelWithTimeout(ct, pw.PluginEvents)
require.NoError(t, err)
resetTestTomb(&testTomb, &pw)
resetTestTomb(t, &testTomb, &pw)
}