mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 04:15:54 +02:00
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:
parent
2c95a24f69
commit
ecf34c2fa1
8 changed files with 87 additions and 126 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue