Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the context.Background() with a testing t.Context(). #448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions artifact/image/layerscanning/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package trace

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -322,7 +321,7 @@
Extractors: []filesystem.Extractor{tc.extractor},
}

PopulateLayerDetails(context.Background(), tc.inventory, tc.chainLayers, config)
PopulateLayerDetails(t.Context(), tc.inventory, tc.chainLayers, config)

Check failure on line 324 in artifact/image/layerscanning/trace/trace_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 324 in artifact/image/layerscanning/trace/trace_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 324 in artifact/image/layerscanning/trace/trace_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 324 in artifact/image/layerscanning/trace/trace_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 324 in artifact/image/layerscanning/trace/trace_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if diff := cmp.Diff(tc.wantInventory, tc.inventory, cmpopts.IgnoreFields(extractor.Inventory{}, "Extractor")); diff != "" {
t.Errorf("PopulateLayerDetails(ctx, %v, %v, config) returned an unexpected diff (-want +got): %v", tc.inventory, tc.chainLayers, diff)
}
Expand Down
3 changes: 1 addition & 2 deletions clients/datasource/http_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package datasource_test

import (
"context"
"net/http"
"testing"

Expand Down Expand Up @@ -304,7 +303,7 @@
}
httpClient := &http.Client{Transport: mt}
for _, want := range tt.expectedResponseCodes {
resp, err := tt.httpAuth.Get(context.Background(), httpClient, tt.requestURL)
resp, err := tt.httpAuth.Get(t.Context(), httpClient, tt.requestURL)

Check failure on line 306 in clients/datasource/http_auth_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 306 in clients/datasource/http_auth_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 306 in clients/datasource/http_auth_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 306 in clients/datasource/http_auth_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 306 in clients/datasource/http_auth_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if err != nil {
t.Fatalf("error making request: %v", err)
}
Expand Down
9 changes: 4 additions & 5 deletions clients/datasource/maven_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package datasource_test

import (
"context"
"reflect"
"testing"

Expand All @@ -35,7 +34,7 @@
</project>
`))

got, err := client.GetProject(context.Background(), "org.example", "x.y.z", "1.0.0")
got, err := client.GetProject(t.Context(), "org.example", "x.y.z", "1.0.0")

Check failure on line 37 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 37 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 37 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 37 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 37 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if err != nil {
t.Fatalf("failed to get Maven project %s:%s verion %s: %v", "org.example", "x.y.z", "1.0.0", err)
}
Expand Down Expand Up @@ -87,7 +86,7 @@
</project>
`))

got, err := client.GetProject(context.Background(), "org.example", "x.y.z", "3.3.1-SNAPSHOT")
got, err := client.GetProject(t.Context(), "org.example", "x.y.z", "3.3.1-SNAPSHOT")

Check failure on line 89 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 89 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 89 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 89 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 89 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if err != nil {
t.Fatalf("failed to get Maven project %s:%s verion %s: %v", "org.example", "x.y.z", "3.3.1-SNAPSHOT", err)
}
Expand Down Expand Up @@ -168,7 +167,7 @@
</project>
`))

gotProj, err := client.GetProject(context.Background(), "org.example", "x.y.z", "1.0.0")
gotProj, err := client.GetProject(t.Context(), "org.example", "x.y.z", "1.0.0")

Check failure on line 170 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 170 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 170 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 170 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 170 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if err != nil {
t.Fatalf("failed to get Maven project %s:%s verion %s: %v", "org.example", "x.y.z", "1.0.0", err)
}
Expand All @@ -183,7 +182,7 @@
t.Errorf("GetProject(%s, %s, %s):\ngot %v\nwant %v\n", "org.example", "x.y.z", "1.0.0", gotProj, wantProj)
}

gotVersions, err := client.GetVersions(context.Background(), "org.example", "x.y.z")
gotVersions, err := client.GetVersions(t.Context(), "org.example", "x.y.z")

Check failure on line 185 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 185 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 185 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 185 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 185 in clients/datasource/maven_registry_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if err != nil {
t.Fatalf("failed to get versions for Maven package %s:%s: %v", "org.example", "x.y.z", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package etcpasswdpermissions_test

import (
"context"
"io/fs"
"runtime"
"slices"
Expand Down Expand Up @@ -123,7 +122,7 @@
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
det := etcpasswdpermissions.Detector{}
findings, err := det.Scan(context.Background(), &scalibrfs.ScanRoot{FS: tc.fsys}, ix)
findings, err := det.Scan(t.Context(), &scalibrfs.ScanRoot{FS: tc.fsys}, ix)

Check failure on line 125 in detector/cis/generic_linux/etcpasswdpermissions/etcpasswdpermissions_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 125 in detector/cis/generic_linux/etcpasswdpermissions/etcpasswdpermissions_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 125 in detector/cis/generic_linux/etcpasswdpermissions/etcpasswdpermissions_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 125 in detector/cis/generic_linux/etcpasswdpermissions/etcpasswdpermissions_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 125 in detector/cis/generic_linux/etcpasswdpermissions/etcpasswdpermissions_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if diff := cmp.Diff(tc.wantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("detector.Scan(%v): unexpected error (-want +got):\n%s", tc.fsys, diff)
}
Expand Down
3 changes: 1 addition & 2 deletions detector/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package detector_test

import (
"context"
"errors"
"testing"

Expand Down Expand Up @@ -153,7 +152,7 @@
ix, _ := inventoryindex.New([]*extractor.Inventory{})
tmp := t.TempDir()
gotFindings, gotStatus, err := detector.Run(
context.Background(), stats.NoopCollector{}, tc.det, scalibrfs.RealFSScanRoot(tmp), ix,
t.Context(), stats.NoopCollector{}, tc.det, scalibrfs.RealFSScanRoot(tmp), ix,

Check failure on line 155 in detector/detector_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 155 in detector/detector_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 155 in detector/detector_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 155 in detector/detector_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 155 in detector/detector_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
)
if diff := cmp.Diff(tc.wantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("detector.Run(%v): unexpected error (-want +got):\n%s", tc.det, diff)
Expand Down
5 changes: 2 additions & 3 deletions detector/govulncheck/binary/binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package binary_test

import (
"context"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -47,7 +46,7 @@
OfflineVulnDBPath: filepath.ToSlash(filepath.Join(wd, "testdata", "vulndb")),
}
ix := setupInventoryIndex([]string{binaryName})
findings, err := det.Scan(context.Background(), scalibrfs.RealFSScanRoot("."), ix)
findings, err := det.Scan(t.Context(), scalibrfs.RealFSScanRoot("."), ix)

Check failure on line 49 in detector/govulncheck/binary/binary_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)

Check failure on line 49 in detector/govulncheck/binary/binary_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context)
if err != nil {
t.Fatalf("detector.Scan(%v): %v", ix, err)
}
Expand Down Expand Up @@ -105,7 +104,7 @@
OfflineVulnDBPath: filepath.ToSlash(filepath.Join(wd, "testdata", "vulndb")),
}
ix := setupInventoryIndex([]string{"nonexistent", binaryName})
result, err := det.Scan(context.Background(), scalibrfs.RealFSScanRoot("."), ix)
result, err := det.Scan(t.Context(), scalibrfs.RealFSScanRoot("."), ix)

Check failure on line 107 in detector/govulncheck/binary/binary_test.go

View workflow job for this annotation

GitHub Actions / lint

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)

Check failure on line 107 in detector/govulncheck/binary/binary_test.go

View workflow job for this annotation

GitHub Actions / lint-just-new

t.Context undefined (type *testing.T has no field or method Context, but does have unexported field context) (typecheck)
if err == nil {
t.Fatalf("detector.Scan(%v): Expected an error, got none", ix)
}
Expand Down
6 changes: 3 additions & 3 deletions detector/weakcredentials/etcshadow/cracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestPasswordHashCracker(t *testing.T) {
"sha512crypt": true,
}
for k, v := range testHashes {
password, err := cracker.Crack(context.Background(), v)
password, err := cracker.Crack(t.Context(), v)
_, isCrackable := crackableHash[k]
if isCrackable && err != nil {
t.Errorf("not cracked supported hash: [%v] [%v]", k, v)
Expand Down Expand Up @@ -81,15 +81,15 @@ func TestPasswordHashCrackerBadHashes(t *testing.T) {
}

for _, v := range badValues {
if _, err := cracker.Crack(context.Background(), v); err != etcshadow.ErrNotCracked {
if _, err := cracker.Crack(t.Context(), v); err != etcshadow.ErrNotCracked {
t.Errorf("expected ErrNotCracked on hash [%s] received [%v]", v, err)
}
}
}

func TestPasswordHashCrackerCancelled(t *testing.T) {
cracker := etcshadow.NewPasswordCracker()
ctx, cancelFunc := context.WithCancel(context.Background())
ctx, cancelFunc := context.WithCancel(t.Context())
cancelFunc()
_, err := cracker.Crack(ctx, testHashes["bcrypt"])
if err != ctx.Err() {
Expand Down
4 changes: 2 additions & 2 deletions detector/weakcredentials/etcshadow/etcshadow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestScan(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
detector := etcshadow.Detector{}
findings, err := detector.Scan(context.Background(), &scalibrfs.ScanRoot{FS: tc.fsys}, ix)
findings, err := detector.Scan(t.Context(), &scalibrfs.ScanRoot{FS: tc.fsys}, ix)
if diff := cmp.Diff(tc.wantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Fatalf("detector.Scan(%v): unexpected error (-want +got):\n%s", tc.fsys, diff)
}
Expand All @@ -163,7 +163,7 @@ func TestScanCancelled(t *testing.T) {
ix, _ := inventoryindex.New([]*extractor.Inventory{})
detector := etcshadow.Detector{}
fsys := &fakeFS{files: map[string]string{"etc/shadow": sampleEtcShadow}}
ctx, cancelFunc := context.WithCancel(context.Background())
ctx, cancelFunc := context.WithCancel(t.Context())
cancelFunc()
findings, err := detector.Scan(ctx, &scalibrfs.ScanRoot{FS: fsys}, ix)
if findings != nil || err != ctx.Err() {
Expand Down
3 changes: 1 addition & 2 deletions detector/weakcredentials/winlocal/winlocal_dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
package winlocal

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
)

func TestScan(t *testing.T) {
d := Detector{}
_, err := d.Scan(context.Background(), nil, nil)
_, err := d.Scan(t.Context(), nil, nil)
if diff := cmp.Diff(err.Error(), "only supported on Windows"); diff != "" {
t.Errorf("Scan(...) unexpected error (-want +got): %v", diff)
}
Expand Down
5 changes: 2 additions & 3 deletions detector/weakcredentials/winlocal/winlocal_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package winlocal

import (
"context"
"slices"
"testing"

Expand Down Expand Up @@ -83,7 +82,7 @@ func TestInternalScan(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
d := Detector{}
findings, err := d.internalScan(context.Background(), tc.hashes)
findings, err := d.internalScan(t.Context(), tc.hashes)
if err != nil {
t.Fatalf("internalScan(...) unexpected error, got: %v, want: %v", err, tc.wantErr)
}
Expand Down Expand Up @@ -154,7 +153,7 @@ func TestBruteforce(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
d := Detector{}
gotMap, err := d.bruteforce(context.Background(), tc.hashes)
gotMap, err := d.bruteforce(t.Context(), tc.hashes)
if err != nil {
t.Fatalf("bruteforce(...) unexpected error: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package containerd_test

import (
"context"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -230,7 +229,7 @@ func TestExtract(t *testing.T) {
}

e := containerd.New(defaultConfigWith(tt.cfg))
got, err := e.Extract(context.Background(), input)
got, err := e.Extract(t.Context(), input)
if !cmp.Equal(err, tt.wantErr, cmpopts.EquateErrors()) {
t.Fatalf("Extract(%+v) error: got %v, want %v\n", tt.path, err, tt.wantErr)
}
Expand Down
11 changes: 5 additions & 6 deletions extractor/filesystem/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package filesystem_test

import (
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -143,7 +142,7 @@ func TestInitWalkContext(t *testing.T) {
scanRoots = append(scanRoots, &scalibrfs.ScanRoot{FS: dummyFS, Path: p})
}
_, err := filesystem.InitWalkContext(
context.Background(), config, scanRoots,
t.Context(), config, scanRoots,
)
if diff := cmp.Diff(tc.wantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("filesystem.InitializeWalkContext(%v) error got diff (-want +got):\n%s", config, diff)
Expand Down Expand Up @@ -563,7 +562,7 @@ func TestRunFS(t *testing.T) {
StoreAbsolutePath: tc.storeAbsPath,
}
wc, err := filesystem.InitWalkContext(
context.Background(), config, []*scalibrfs.ScanRoot{{
t.Context(), config, []*scalibrfs.ScanRoot{{
FS: fsys, Path: cwd,
}},
)
Expand All @@ -573,7 +572,7 @@ func TestRunFS(t *testing.T) {
if err = wc.UpdateScanRoot(cwd, fsys); err != nil {
t.Fatalf("wc.UpdateScanRoot(..., %v): %v", fsys, err)
}
gotInv, gotStatus, err := filesystem.RunFS(context.Background(), config, wc)
gotInv, gotStatus, err := filesystem.RunFS(t.Context(), config, wc)
if diff := cmp.Diff(tc.wantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("extractor.Run(%v) error got diff (-want +got):\n%s", tc.ex, diff)
}
Expand Down Expand Up @@ -694,14 +693,14 @@ func TestRunFS_ReadError(t *testing.T) {
}},
Stats: stats.NoopCollector{},
}
wc, err := filesystem.InitWalkContext(context.Background(), config, config.ScanRoots)
wc, err := filesystem.InitWalkContext(t.Context(), config, config.ScanRoots)
if err != nil {
t.Fatalf("filesystem.InitializeWalkContext(%v): %v", config, err)
}
if err := wc.UpdateScanRoot(".", fsys); err != nil {
t.Fatalf("wc.UpdateScanRoot(%v): %v", config, err)
}
gotInv, gotStatus, err := filesystem.RunFS(context.Background(), config, wc)
gotInv, gotStatus, err := filesystem.RunFS(t.Context(), config, wc)
if err != nil {
t.Fatalf("extractor.Run(%v): %v", ex, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package conanlock_test

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -164,7 +163,7 @@ func TestExtractor_Extract_v1_revisions(t *testing.T) {
scanInput := extracttest.GenerateScanInputMock(t, tt.InputConfig)
defer extracttest.CloseTestScanInput(t, scanInput)

got, err := extr.Extract(context.Background(), &scanInput)
got, err := extr.Extract(t.Context(), &scanInput)

if diff := cmp.Diff(tt.WantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("%s.Extract(%q) error diff (-want +got):\n%s", extr.Name(), tt.InputConfig.Path, diff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package conanlock_test

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -236,7 +235,7 @@ func TestExtractor_Extract_v1(t *testing.T) {
scanInput := extracttest.GenerateScanInputMock(t, tt.InputConfig)
defer extracttest.CloseTestScanInput(t, scanInput)

got, err := extr.Extract(context.Background(), &scanInput)
got, err := extr.Extract(t.Context(), &scanInput)

if diff := cmp.Diff(tt.WantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("%s.Extract(%q) error diff (-want +got):\n%s", extr.Name(), tt.InputConfig.Path, diff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package conanlock_test

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -164,7 +163,7 @@ func TestExtractor_Extract_v2(t *testing.T) {
scanInput := extracttest.GenerateScanInputMock(t, tt.InputConfig)
defer extracttest.CloseTestScanInput(t, scanInput)

got, err := extr.Extract(context.Background(), &scanInput)
got, err := extr.Extract(t.Context(), &scanInput)

if diff := cmp.Diff(tt.WantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("%s.Extract(%q) error diff (-want +got):\n%s", extr.Name(), tt.InputConfig.Path, diff)
Expand Down
3 changes: 1 addition & 2 deletions extractor/filesystem/language/dart/pubspec/pubspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package pubspec_test

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -296,7 +295,7 @@ func TestExtractor_Extract(t *testing.T) {
scanInput := extracttest.GenerateScanInputMock(t, tt.InputConfig)
defer extracttest.CloseTestScanInput(t, scanInput)

got, err := extr.Extract(context.Background(), &scanInput)
got, err := extr.Extract(t.Context(), &scanInput)

if diff := cmp.Diff(tt.WantErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("%s.Extract(%q) error diff (-want +got):\n%s", extr.Name(), tt.InputConfig.Path, diff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package depsjson_test

import (
"context"
"io/fs"
"os"
"path/filepath"
Expand Down Expand Up @@ -277,7 +276,7 @@ func TestExtract(t *testing.T) {
FS: scalibrfs.DirFS(d), Path: tt.path, Reader: r, Root: d, Info: info,
}

got, err := e.Extract(context.Background(), input)
got, err := e.Extract(t.Context(), input)

if diff := cmp.Diff(tt.wantInventory, got, cmpopts.SortSlices(invLess)); diff != "" {
t.Errorf("Inventory mismatch (-want +got):\n%s", diff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
package packagesconfig_test

import (
"context"
"io/fs"
"path/filepath"
"testing"
Expand Down Expand Up @@ -240,7 +239,7 @@ func TestExtract(t *testing.T) {
scanInput := extracttest.GenerateScanInputMock(t, tt.InputConfig)
defer extracttest.CloseTestScanInput(t, scanInput)

got, err := e.Extract(context.Background(), &scanInput)
got, err := e.Extract(t.Context(), &scanInput)

// Compare errors if any
if diff := cmp.Diff(tt.WantErr, err, cmpopts.EquateErrors()); diff != "" {
Expand Down
Loading