From d8eb10a8e9a2f747c048c8ae3e3aa6542a0b6f26 Mon Sep 17 00:00:00 2001 From: Ahrav Dutta Date: Mon, 31 Jul 2023 07:13:42 -0700 Subject: [PATCH] fix test. --- pkg/engine/gcs_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/engine/gcs_test.go b/pkg/engine/gcs_test.go index d1b225f91a67..b62783408a9d 100644 --- a/pkg/engine/gcs_test.go +++ b/pkg/engine/gcs_test.go @@ -4,6 +4,8 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/trufflesecurity/trufflehog/v3/pkg/context" "github.com/trufflesecurity/trufflehog/v3/pkg/decoders" "github.com/trufflesecurity/trufflehog/v3/pkg/sources" @@ -59,11 +61,13 @@ func TestScanGCS(t *testing.T) { ctx, cancel := context.WithCancel(context.TODO()) defer cancel() - e := Start(ctx, + e, err := Start(ctx, WithConcurrency(1), WithDecoders(decoders.DefaultDecoders()...), WithDetectors(false, DefaultDetectors()...), ) + assert.Nil(t, err) + go func() { resultCount := 0 for range e.ResultsChan() { @@ -71,15 +75,12 @@ func TestScanGCS(t *testing.T) { } }() - err := e.ScanGCS(ctx, test.gcsConfig) + err = e.ScanGCS(ctx, test.gcsConfig) if err != nil && !test.wantErr && !strings.Contains(err.Error(), "googleapi: Error 400: Bad Request") { t.Errorf("ScanGCS() got: %v, want: %v", err, nil) return } - logFatalFunc := func(_ error, _ string, _ ...any) { - t.Fatalf("error logging function should not have been called") - } - e.Finish(ctx, logFatalFunc) + assert.Nil(t, e.Finish(ctx)) if err == nil && test.wantErr { t.Errorf("ScanGCS() got: %v, want: %v", err, "error")