From 88fcc9fcda2325bca59ae0b051b27f1ac00ad4b3 Mon Sep 17 00:00:00 2001 From: Zubair Khan Date: Wed, 23 Aug 2023 16:32:04 -0400 Subject: [PATCH] reuuse the args context --- pkg/detectors/snowflake/snowflake.go | 7 +++---- pkg/detectors/snowflake/snowflake_test.go | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/detectors/snowflake/snowflake.go b/pkg/detectors/snowflake/snowflake.go index 4f0836b04925..c7bcbc4221f6 100644 --- a/pkg/detectors/snowflake/snowflake.go +++ b/pkg/detectors/snowflake/snowflake.go @@ -14,7 +14,6 @@ import ( ) type Scanner struct { - context context.Context } // Ensure the Scanner satisfies the interface at compile time. @@ -109,11 +108,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } defer db.Close() - if s.context == nil { - s.context = context.Background() + if ctx == nil { + ctx = context.Background() } - err = db.PingContext(s.context) + err = db.PingContext(ctx) if err != nil { if strings.Contains(err.Error(), "Incorrect username or password was specified") { s1.Verified = false diff --git a/pkg/detectors/snowflake/snowflake_test.go b/pkg/detectors/snowflake/snowflake_test.go index 771be31c5b00..87af00365dfd 100644 --- a/pkg/detectors/snowflake/snowflake_test.go +++ b/pkg/detectors/snowflake/snowflake_test.go @@ -103,11 +103,9 @@ func TestSnowflake_FromChunk(t *testing.T) { }, { name: "found, indeterminate error (timeout)", - s: Scanner{ - context: errorCtx, - }, + s: Scanner{}, args: args{ - ctx: context.Background(), + ctx: errorCtx, data: []byte(fmt.Sprintf("snowflake: \n account=tuacoip-zt74995 \n username=zubairkhan14 \n password=%s \n database=SNOWFLAKE", secret)), verify: true, },