Skip to content

Commit

Permalink
reuuse the args context
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairk14 committed Aug 23, 2023
1 parent 389eb8f commit 88fcc9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions pkg/detectors/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

type Scanner struct {
context context.Context
}

// Ensure the Scanner satisfies the interface at compile time.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions pkg/detectors/snowflake/snowflake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 88fcc9f

Please sign in to comment.