chore: replace deprecated tenv linter with usetesting (#8504)

This commit is contained in:
Teppei Fukuda
2025-03-06 16:26:20 +04:00
committed by GitHub
parent e5072f1eef
commit fe09410ed4
150 changed files with 366 additions and 509 deletions

View File

@@ -114,7 +114,7 @@ linters:
- misspell
- perfsprint
- revive
- tenv
- usetesting
- testifylint
- typecheck
- unconvert

View File

@@ -1,7 +1,6 @@
package sbom_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
@@ -41,7 +40,7 @@ func TestRekor_RetrieveSBOM(t *testing.T) {
rc, err := sbom.NewRekor(ts.URL())
require.NoError(t, err)
got, err := rc.RetrieveSBOM(context.Background(), tt.digest)
got, err := rc.RetrieveSBOM(t.Context(), tt.digest)
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)
return

View File

@@ -1,7 +1,6 @@
package auth_test
import (
"context"
"os"
"path/filepath"
"strings"
@@ -103,7 +102,7 @@ func TestLogin(t *testing.T) {
t.Setenv("DOCKER_CONFIG", filepath.Join(t.TempDir(), "config.json"))
reg := lo.Ternary(tt.args.registry == "", strings.TrimPrefix(tr.URL, "http://"), tt.args.registry)
err := auth.Login(context.Background(), reg, tt.args.opts)
err := auth.Login(t.Context(), reg, tt.args.opts)
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)
return
@@ -124,19 +123,19 @@ func TestLogout(t *testing.T) {
err := os.WriteFile(configFile, []byte(`{"auths": {"auth.test": {"auth": "dXNlcjpwYXNz"}}}`), 0600)
require.NoError(t, err)
err = auth.Logout(context.Background(), "auth.test")
err = auth.Logout(t.Context(), "auth.test")
require.NoError(t, err)
b, err := os.ReadFile(configFile)
require.NoError(t, err)
require.JSONEq(t, `{"auths": {}}`, string(b))
})
t.Run("not found", func(t *testing.T) {
err := auth.Logout(context.Background(), "notfound.test")
err := auth.Logout(t.Context(), "notfound.test")
require.NoError(t, err) // Return an error if "credsStore" is "osxkeychain".
})
t.Run("invalid registry", func(t *testing.T) {
err := auth.Logout(context.Background(), "aaa://invalid.test")
err := auth.Logout(t.Context(), "aaa://invalid.test")
require.ErrorContains(t, err, "registries must be valid RFC 3986 URI authorities")
})
}

View File

@@ -1,7 +1,6 @@
package clean_test
import (
"context"
"os"
"path/filepath"
"testing"
@@ -130,7 +129,7 @@ func TestRun(t *testing.T) {
CleanOptions: tt.cleanOpts,
}
err := clean.Run(context.Background(), opts)
err := clean.Run(t.Context(), opts)
if tt.wantErr {
assert.Error(t, err)

View File

@@ -2,7 +2,6 @@ package report_test
import (
"bytes"
"context"
"os"
"path/filepath"
"testing"
@@ -73,7 +72,7 @@ func TestTableWriter_Write(t *testing.T) {
Report: tt.reportType,
Output: buf,
}
err := tr.Write(context.Background(), tt.input)
err := tr.Write(t.Context(), tt.input)
require.NoError(t, err)
want, err := os.ReadFile(tt.want)

View File

@@ -1,7 +1,6 @@
package db_test
import (
"context"
"fmt"
"testing"
"time"
@@ -147,7 +146,7 @@ func TestClient_NeedsUpdate(t *testing.T) {
}
// Set a fake time
ctx := clock.With(context.Background(), time.Date(2019, 10, 1, 0, 0, 0, 0, time.UTC))
ctx := clock.With(t.Context(), time.Date(2019, 10, 1, 0, 0, 0, 0, time.UTC))
client := db.NewClient(dbDir, true)
needsUpdate, err := client.NeedsUpdate(ctx, "test", tt.skip)
@@ -191,7 +190,7 @@ func TestClient_Download(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Set a fake time
ctx := clock.With(context.Background(), time.Date(2019, 10, 1, 0, 0, 0, 0, time.UTC))
ctx := clock.With(t.Context(), time.Date(2019, 10, 1, 0, 0, 0, 0, time.UTC))
// Fake DB
art := dbtest.NewFakeDB(t, tt.input, dbtest.FakeDBOptions{})

View File

@@ -1,7 +1,6 @@
package alma_test
import (
"context"
"testing"
"time"
@@ -215,7 +214,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := alma.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package alpine_test
import (
"context"
"sort"
"testing"
"time"
@@ -326,7 +325,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := alpine.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package amazon_test
import (
"context"
"testing"
"time"
@@ -248,7 +247,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := amazon.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package debian_test
import (
"context"
"sort"
"testing"
"time"
@@ -172,7 +171,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := debian.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package oracle
import (
"context"
"testing"
"time"
@@ -83,7 +82,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
for testName, tt := range tests {
s := NewScanner()
t.Run(testName, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
actual := s.IsSupportedVersion(ctx, tt.osFamily, tt.osVersion)
if actual != tt.expected {
t.Errorf("[%s] got %v, want %v", testName, actual, tt.expected)

View File

@@ -1,7 +1,6 @@
package photon_test
import (
"context"
"testing"
"time"
@@ -147,7 +146,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := photon.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package redhat_test
import (
"context"
"os"
"testing"
"time"
@@ -494,7 +493,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := redhat.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package rocky_test
import (
"context"
"testing"
"time"
@@ -175,7 +174,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := rocky.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package suse_test
import (
"context"
"testing"
"time"
@@ -283,7 +282,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := suse.NewScanner(tt.distribution)
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package ubuntu_test
import (
"context"
"sort"
"testing"
"time"
@@ -253,7 +252,7 @@ func TestScanner_IsSupportedVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := clock.With(context.Background(), tt.now)
ctx := clock.With(t.Context(), tt.now)
s := ubuntu.NewScanner()
got := s.IsSupportedVersion(ctx, tt.args.osFamily, tt.args.osVer)
assert.Equal(t, tt.want, got)

View File

@@ -1,7 +1,6 @@
package downloader_test
import (
"context"
"net/http"
"net/http/httptest"
"os"
@@ -44,7 +43,7 @@ func TestDownload(t *testing.T) {
dst := t.TempDir()
// Execute the download
_, err := downloader.Download(context.Background(), server.URL, dst, "", downloader.Options{
_, err := downloader.Download(t.Context(), server.URL, dst, "", downloader.Options{
Insecure: tt.insecure,
})

View File

@@ -1,7 +1,6 @@
package analyzer_test
import (
"context"
"os"
"sync"
"testing"
@@ -529,7 +528,7 @@ func TestAnalyzerGroup_AnalyzeFile(t *testing.T) {
info, err := os.Stat(tt.args.testFilePath)
require.NoError(t, err)
ctx := context.Background()
ctx := t.Context()
err = a.AnalyzeFile(ctx, &wg, limit, got, "", tt.args.filePath, info,
func() (xio.ReadSeekCloserAt, error) {
if tt.args.testFilePath == "testdata/error" {
@@ -625,7 +624,7 @@ func TestAnalyzerGroup_PostAnalyze(t *testing.T) {
javadb.Init("./language/java/jar/testdata", []name.Reference{repo}, true, false, types.RegistryOptions{Insecure: false})
}
ctx := context.Background()
ctx := t.Context()
got := new(analyzer.AnalysisResult)
err = a.PostAnalyze(ctx, composite, got, analyzer.AnalysisOptions{})
require.NoError(t, err)

View File

@@ -1,7 +1,6 @@
package buildinfo
import (
"context"
"os"
"testing"
@@ -49,7 +48,7 @@ func Test_contentManifestAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := contentManifestAnalyzer{}
got, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: tt.input,
Content: f,
})

View File

@@ -1,7 +1,6 @@
package buildinfo
import (
"context"
"os"
"testing"
@@ -52,7 +51,7 @@ func Test_dockerfileAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := dockerfileAnalyzer{}
got, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,
})

View File

@@ -1,7 +1,6 @@
package config_test
import (
"context"
"os"
"testing"
@@ -94,7 +93,7 @@ func TestAnalyzer_PostAnalyze(t *testing.T) {
a, err := config.NewAnalyzer(tt.fields.typ, 0, tt.fields.fileType, tt.fields.opts)
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})
if tt.wantErr != "" {

View File

@@ -116,7 +116,7 @@ func TestAnalyzeConfig(t *testing.T) {
DisabledAnalyzers: tt.args.disabledAnalyzers,
})
require.NoError(t, err)
got := a.AnalyzeImageConfig(context.Background(), tt.args.targetOS, tt.args.config)
got := a.AnalyzeImageConfig(t.Context(), tt.args.targetOS, tt.args.config)
assert.Equal(t, tt.want, got)
})
}

View File

@@ -1,7 +1,6 @@
package executable
import (
"context"
"os"
"testing"
@@ -42,7 +41,7 @@ func Test_executableAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
a := executableAnalyzer{}
got, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: tt.filePath,
Content: f,
Info: stat,

View File

@@ -1,7 +1,6 @@
package apk
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
@@ -1423,7 +1422,7 @@ func TestAnalyze(t *testing.T) {
t.Setenv(envApkIndexArchiveURL, v.apkIndexArchivePath)
a, err := newAlpineCmdAnalyzer(analyzer.ConfigAnalyzerOptions{})
require.NoError(t, err)
result, err := a.Analyze(context.Background(), analyzer.ConfigAnalysisInput{
result, err := a.Analyze(t.Context(), analyzer.ConfigAnalysisInput{
OS: v.args.targetOS,
Config: v.args.config,
})

View File

@@ -2,7 +2,6 @@ package dockerfile
import (
"bytes"
"context"
"testing"
"time"
@@ -332,7 +331,7 @@ func Test_historyAnalyzer_Analyze(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
a, err := newHistoryAnalyzer(analyzer.ConfigAnalyzerOptions{})
require.NoError(t, err)
got, err := a.Analyze(context.Background(), tt.input)
got, err := a.Analyze(t.Context(), tt.input)
if tt.wantErr {
require.Error(t, err)
return

View File

@@ -1,7 +1,6 @@
package secret
import (
"context"
"testing"
v1 "github.com/google/go-containerregistry/pkg/v1"
@@ -95,7 +94,7 @@ func Test_secretAnalyzer_Analyze(t *testing.T) {
a, err := newSecretAnalyzer(analyzer.ConfigAnalyzerOptions{})
require.NoError(t, err)
got, err := a.Analyze(context.Background(), analyzer.ConfigAnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.ConfigAnalysisInput{
Config: tt.config,
})
if tt.wantErr {

View File

@@ -1,7 +1,6 @@
package conan
import (
"context"
"os"
"testing"
@@ -216,7 +215,7 @@ func Test_conanLockAnalyzer_Analyze(t *testing.T) {
a, err := newConanLockAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package environment
import (
"context"
"os"
"testing"
@@ -148,7 +147,7 @@ func Test_environmentAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := environmentAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package meta
import (
"context"
"os"
"testing"
@@ -55,7 +54,7 @@ func Test_packagingAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
a := metaAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Info: stat,

View File

@@ -1,7 +1,6 @@
package pub
import (
"context"
"os"
"runtime"
"testing"
@@ -133,7 +132,7 @@ func Test_pubSpecLockAnalyzer_Analyze(t *testing.T) {
a, err := newPubSpecLockAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package deps
import (
"context"
"os"
"testing"
@@ -57,7 +56,7 @@ func Test_depsLibraryAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := depsLibraryAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package nuget
import (
"context"
"os"
"testing"
@@ -197,7 +196,7 @@ func Test_nugetLibraryAnalyzer_Analyze(t *testing.T) {
a, err := newNugetLibraryAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package packagesprops
import (
"context"
"os"
"testing"
@@ -80,7 +79,7 @@ func Test_packagesPropsAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := packagesPropsAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package binary
import (
"context"
"os"
"runtime"
"testing"
@@ -83,7 +82,7 @@ func Test_gobinaryLibraryAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := gobinaryLibraryAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package mod
import (
"context"
"path/filepath"
"sort"
"testing"
@@ -302,7 +301,7 @@ func Test_gomodAnalyzer_Analyze(t *testing.T) {
}
}
ctx := context.Background()
ctx := t.Context()
got, err := a.PostAnalyze(ctx, analyzer.PostAnalysisInput{
FS: mfs,
})

View File

@@ -1,7 +1,6 @@
package gradle
import (
"context"
"os"
"testing"
@@ -118,7 +117,7 @@ func Test_gradleLockAnalyzer_Analyze(t *testing.T) {
a, err := newGradleLockAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package jar
import (
"context"
"os"
"path/filepath"
"testing"
@@ -133,7 +132,7 @@ func Test_javaLibraryAnalyzer_Analyze(t *testing.T) {
javadb.Init("testdata", []name.Reference{repo}, true, false, types.RegistryOptions{Insecure: false})
a := javaLibraryAnalyzer{}
ctx := context.Background()
ctx := t.Context()
mfs := mapfs.New()
err = mfs.MkdirAll(filepath.Dir(tt.inputFile), os.ModePerm)

View File

@@ -1,7 +1,6 @@
package sbt
import (
"context"
"os"
"testing"
@@ -78,7 +77,7 @@ func Test_sbtDependencyLockAnalyzer(t *testing.T) {
require.NoError(t, err)
a := sbtDependencyLockAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,

View File

@@ -1,7 +1,6 @@
package pkgjl
import (
"context"
"os"
"testing"
@@ -199,7 +198,7 @@ func Test_juliaAnalyzer_Analyze(t *testing.T) {
a, err := newJuliaAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package npm
import (
"context"
"os"
"sort"
"testing"
@@ -235,7 +234,7 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) {
a, err := newNpmLibraryAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package pkg
import (
"context"
"os"
"testing"
@@ -81,7 +80,7 @@ func Test_nodePkgLibraryAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := nodePkgLibraryAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package pnpm
import (
"context"
"os"
"sort"
"testing"
@@ -111,7 +110,7 @@ func Test_pnpmPkgLibraryAnalyzer_Analyze(t *testing.T) {
a, err := newPnpmAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package yarn
import (
"context"
"os"
"testing"
@@ -822,7 +821,7 @@ func Test_yarnLibraryAnalyzer_Analyze(t *testing.T) {
a, err := newYarnAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package composer
import (
"context"
"os"
"testing"
@@ -159,7 +158,7 @@ func Test_composerAnalyzer_PostAnalyze(t *testing.T) {
a, err := newComposerAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package packaging
import (
"context"
"os"
"testing"
@@ -103,7 +102,7 @@ func Test_eggAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
a := &eggAnalyzer{}
got, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
Content: f,
FilePath: tt.inputFile,
Info: fileInfo,

View File

@@ -1,7 +1,6 @@
package packaging
import (
"context"
"os"
"testing"
@@ -133,7 +132,7 @@ func Test_packagingAnalyzer_Analyze(t *testing.T) {
a, err := newPackagingAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
Options: analyzer.AnalysisOptions{
FileChecksum: tt.includeChecksum,

View File

@@ -1,7 +1,6 @@
package pip
import (
"context"
"os"
"path/filepath"
"runtime"
@@ -176,7 +175,7 @@ func Test_pipAnalyzer_Analyze(t *testing.T) {
a, err := newPipLibraryAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package poetry
import (
"context"
"os"
"testing"
@@ -557,7 +556,7 @@ func Test_poetryLibraryAnalyzer_Analyze(t *testing.T) {
a, err := newPoetryAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package uv_test
import (
"context"
"os"
"testing"
@@ -160,7 +159,7 @@ func Test_uvAnalyzer_PostAnalyze(t *testing.T) {
a, err := uv.NewUvAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package gemspec
import (
"context"
"os"
"testing"
@@ -84,7 +83,7 @@ func Test_gemspecLibraryAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := gemspecLibraryAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package binary
import (
"context"
"os"
"runtime"
"testing"
@@ -63,7 +62,7 @@ func Test_rustBinaryLibraryAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := rustBinaryLibraryAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.inputFile,
Content: f,

View File

@@ -1,7 +1,6 @@
package cargo
import (
"context"
"os"
"testing"
@@ -546,7 +545,7 @@ func Test_cargoAnalyzer_Analyze(t *testing.T) {
a, err := newCargoAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{
got, err := a.PostAnalyze(t.Context(), analyzer.PostAnalysisInput{
FS: os.DirFS(tt.dir),
})

View File

@@ -1,7 +1,6 @@
package licensing
import (
"context"
"os"
"testing"
@@ -54,7 +53,7 @@ func Test_licenseAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
a := newLicenseFileAnalyzer()
got, err := a.Analyze(context.TODO(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: tt.filePath,
Content: f,
Info: fi,

View File

@@ -1,7 +1,6 @@
package alpine
import (
"context"
"strings"
"testing"
@@ -37,7 +36,7 @@ func TestAlpineReleaseOSAnalyzer_Required(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
a := alpineOSAnalyzer{}
res, err := a.Analyze(context.Background(), test.input)
res, err := a.Analyze(t.Context(), test.input)
if test.wantError != "" {
require.Error(t, err)

View File

@@ -1,7 +1,6 @@
package amazonlinux
import (
"context"
"strings"
"testing"
@@ -92,7 +91,7 @@ func Test_amazonlinuxOSAnalyzer_Analyze(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := amazonlinuxOSAnalyzer{}
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, tt.input)
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)

View File

@@ -1,7 +1,6 @@
package debian
import (
"context"
"os"
"testing"
@@ -52,7 +51,7 @@ func Test_debianOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/debian_version",

View File

@@ -1,7 +1,6 @@
package redhatbase
import (
"context"
"os"
"testing"
@@ -39,7 +38,7 @@ func Test_almaOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/almalinux-release",

View File

@@ -1,7 +1,6 @@
package redhatbase
import (
"context"
"os"
"testing"
@@ -38,7 +37,7 @@ func Test_centosOSAnalyzer_Analyze(t *testing.T) {
f, err := os.Open(tt.inputFile)
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/centos-release",

View File

@@ -1,7 +1,6 @@
package redhatbase
import (
"context"
"os"
"testing"
@@ -39,7 +38,7 @@ func Test_fedoraOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/fedora-release",
Content: f,

View File

@@ -1,7 +1,6 @@
package redhatbase
import (
"context"
"os"
"testing"
@@ -39,7 +38,7 @@ func Test_oracleOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/oracle-release",
Content: f,

View File

@@ -1,7 +1,6 @@
package redhatbase
import (
"context"
"os"
"testing"
@@ -39,7 +38,7 @@ func Test_redhatOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/redhat-release",
Content: f,

View File

@@ -1,7 +1,6 @@
package redhatbase
import (
"context"
"os"
"testing"
@@ -39,7 +38,7 @@ func Test_rockyOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/rocky-release",
Content: f,

View File

@@ -1,7 +1,6 @@
package release
import (
"context"
"os"
"testing"
@@ -174,7 +173,7 @@ func Test_osReleaseAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := osReleaseAnalyzer{}
res, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
res, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: "etc/os-release",
Content: f,
})

View File

@@ -1,7 +1,6 @@
package ubuntu
import (
"context"
"os"
"testing"
@@ -48,7 +47,7 @@ func Test_ubuntuESMAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: tt.filePath,
Content: f,

View File

@@ -1,7 +1,6 @@
package ubuntu
import (
"context"
"os"
"testing"
@@ -39,7 +38,7 @@ func Test_ubuntuOSAnalyzer_Analyze(t *testing.T) {
require.NoError(t, err)
defer f.Close()
ctx := context.Background()
ctx := t.Context()
got, err := a.Analyze(ctx, analyzer.AnalysisInput{
FilePath: "etc/lsb-release",
Content: f,

View File

@@ -2,7 +2,6 @@ package apk
import (
"bufio"
"context"
"os"
"testing"
@@ -443,7 +442,7 @@ func TestParseApkInfo(t *testing.T) {
require.NoError(t, err)
defer f.Close()
scanner := bufio.NewScanner(f)
gotPkgs, gotFiles := a.parseApkInfo(context.Background(), scanner)
gotPkgs, gotFiles := a.parseApkInfo(t.Context(), scanner)
assert.Equal(t, tt.wantPkgs, gotPkgs)
assert.Equal(t, tt.wantFiles, gotFiles)

View File

@@ -1,7 +1,6 @@
package dpkg
import (
"context"
"os"
"testing"
@@ -93,7 +92,7 @@ func Test_dpkgLicenseAnalyzer_Analyze(t *testing.T) {
}
a := dpkgLicenseAnalyzer{}
license, err := a.Analyze(context.Background(), input)
license, err := a.Analyze(t.Context(), input)
require.NoError(t, err)
assert.Equal(t, tt.want, license)
})

View File

@@ -1,7 +1,6 @@
package dpkg
import (
"context"
"os"
"path/filepath"
"sort"
@@ -1445,7 +1444,7 @@ func Test_dpkgAnalyzer_Analyze(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
a, err := newDpkgAnalyzer(analyzer.AnalyzerOptions{})
require.NoError(t, err)
ctx := context.Background()
ctx := t.Context()
mfs := mapfs.New()
for testPath, osPath := range tt.testFiles {

View File

@@ -1,7 +1,6 @@
package rpm
import (
"context"
"os"
"strings"
"testing"
@@ -79,7 +78,7 @@ func Test_rpmArchiveAnalyzer_Analyze(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := newRPMArchiveAnalyzer()
got, err := a.Analyze(context.Background(), tt.input)
got, err := a.Analyze(t.Context(), tt.input)
tt.wantErr(t, err)
assert.Equal(t, tt.want, got)
})

View File

@@ -1,7 +1,6 @@
package rpm
import (
"context"
"errors"
"os"
"strings"
@@ -56,7 +55,7 @@ func Test_rpmPkgAnalyzer_Analyze(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := rpmPkgAnalyzer{}
got, err := a.Analyze(context.Background(), tt.input)
got, err := a.Analyze(t.Context(), tt.input)
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)
return
@@ -273,7 +272,7 @@ func Test_rpmPkgAnalyzer_listPkgs(t *testing.T) {
}
a := newRPMPkgAnalyzer()
gotPkgs, gotFiles, err := a.listPkgs(context.Background(), m)
gotPkgs, gotFiles, err := a.listPkgs(t.Context(), m)
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)
return

View File

@@ -1,7 +1,6 @@
package apk
import (
"context"
"strings"
"testing"
@@ -150,7 +149,7 @@ https://dl-cdn.alpinelinux.org/alpine/v3.10/main
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
a := apkRepoAnalyzer{}
got, err := a.Analyze(context.Background(), test.input)
got, err := a.Analyze(t.Context(), test.input)
if test.wantErr != "" {
require.Error(t, err)

View File

@@ -1,7 +1,6 @@
package sbom
import (
"context"
"os"
"testing"
@@ -340,7 +339,7 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
defer f.Close()
a := sbomAnalyzer{}
got, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: tt.filePath,
Content: f,
})

View File

@@ -1,7 +1,6 @@
package secret_test
import (
"context"
"os"
"testing"
@@ -192,7 +191,7 @@ func TestSecretAnalyzer(t *testing.T) {
fi, err := content.Stat()
require.NoError(t, err)
got, err := a.Analyze(context.Background(), analyzer.AnalysisInput{
got, err := a.Analyze(t.Context(), analyzer.AnalysisInput{
FilePath: tt.filePath,
Dir: tt.dir,
Content: content,

View File

@@ -1,7 +1,6 @@
package image_test
import (
"context"
"math/rand"
"testing"
"time"
@@ -2016,7 +2015,7 @@ func TestArtifact_Inspect(t *testing.T) {
a, err := image2.NewArtifact(img, c, tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr, tt.name)
return
@@ -2065,7 +2064,7 @@ func TestArtifact_InspectWithMaxImageSize(t *testing.T) {
artifact, err := image2.NewArtifact(img, c, tt.artifactOpt)
require.NoError(t, err)
_, err = artifact.Inspect(context.Background())
_, err = artifact.Inspect(t.Context())
require.ErrorContains(t, err, tt.wantErr)
})
}

View File

@@ -1,7 +1,6 @@
package image_test
import (
"context"
"net/http"
"net/http/httptest"
"net/url"
@@ -161,7 +160,7 @@ func TestArtifact_InspectRekorAttestation(t *testing.T) {
a, err := image2.NewArtifact(img, c, tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)
return
@@ -304,7 +303,7 @@ func TestArtifact_inspectOCIReferrerSBOM(t *testing.T) {
a, err := image2.NewArtifact(img, c, tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)
return

View File

@@ -1,7 +1,6 @@
package local
import (
"context"
"os"
"path/filepath"
"testing"
@@ -228,7 +227,7 @@ func TestArtifact_Inspect(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)
return
@@ -638,7 +637,7 @@ func TestTerraformMisconfigurationScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
assert.Equal(t, tt.want, got)
cachetest.AssertBlobs(t, c, tt.wantBlobs)
@@ -892,7 +891,7 @@ func TestTerraformPlanSnapshotMisconfScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), opt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
assert.Equal(t, tt.want, got)
cachetest.AssertBlobs(t, c, tt.wantBlobs)
@@ -1204,7 +1203,7 @@ func TestCloudFormationMisconfigurationScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
assert.Equal(t, tt.want, got)
cachetest.AssertBlobs(t, c, tt.wantBlobs)
@@ -1432,7 +1431,7 @@ func TestDockerfileMisconfigurationScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
assert.Equal(t, tt.want, got)
cachetest.AssertBlobs(t, c, tt.wantBlobs)
@@ -1693,7 +1692,7 @@ func TestKubernetesMisconfigurationScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
assert.Equal(t, tt.want, got)
cachetest.AssertBlobs(t, c, tt.wantBlobs)
@@ -1946,7 +1945,7 @@ func TestAzureARMMisconfigurationScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
assert.Equal(t, tt.want, got)
cachetest.AssertBlobs(t, c, tt.wantBlobs)
@@ -2063,7 +2062,7 @@ func TestMixedConfigurationScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
require.NotNil(t, got)
@@ -2225,7 +2224,7 @@ func TestJSONConfigScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
require.NotNil(t, got)
@@ -2387,7 +2386,7 @@ func TestYAMLConfigScan(t *testing.T) {
a, err := NewArtifact(tt.fields.dir, c, walker.NewFS(), tt.artifactOpt)
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
require.NoError(t, err)
require.NotNil(t, got)

View File

@@ -3,7 +3,6 @@
package repo
import (
"context"
"os"
"path/filepath"
"testing"
@@ -278,7 +277,7 @@ func TestArtifact_Inspect(t *testing.T) {
require.NoError(t, err)
defer cleanup()
ref, err := art.Inspect(context.Background())
ref, err := art.Inspect(t.Context())
if tt.wantErr {
assert.Error(t, err)
return

View File

@@ -1,7 +1,6 @@
package sbom_test
import (
"context"
"path/filepath"
"strings"
"testing"
@@ -394,7 +393,7 @@ func TestArtifact_Inspect(t *testing.T) {
a, err := sbom.NewArtifact(tt.filePath, c, artifact.Option{})
require.NoError(t, err)
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
if len(tt.wantErr) > 0 {
require.Error(t, err)
found := false

View File

@@ -1,7 +1,6 @@
package vm_test
import (
"context"
"fmt"
"io"
"io/fs"
@@ -166,7 +165,7 @@ func TestArtifact_Inspect(t *testing.T) {
aa.SetEBS(ebs)
}
got, err := a.Inspect(context.Background())
got, err := a.Inspect(t.Context())
defer a.Clean(got)
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)

View File

@@ -99,7 +99,7 @@ func TestManager_CallHooks(t *testing.T) {
})
require.NoError(t, err)
err = m.PostHandle(context.TODO(), nil, &blob)
err = m.PostHandle(t.Context(), nil, &blob)
require.NoError(t, err)
assert.Equal(t, tt.want, blob)
})

View File

@@ -1,7 +1,6 @@
package nodejs
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
@@ -260,7 +259,7 @@ func Test_systemFileFilterHook_Hook(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := systemFileFilteringPostHandler{}
err := h.Handle(context.TODO(), tt.result, tt.blob)
err := h.Handle(t.Context(), tt.result, tt.blob)
require.NoError(t, err)
assert.Equal(t, tt.want, tt.blob)
})

View File

@@ -1,7 +1,6 @@
package unpackaged_test
import (
"context"
"testing"
"github.com/package-url/packageurl-go"
@@ -89,7 +88,7 @@ func Test_unpackagedHook_Handle(t *testing.T) {
h, err := unpackaged.NewUnpackagedHandler(opt)
require.NoError(t, err)
err = h.Handle(context.Background(), tt.args.res, got)
err = h.Handle(t.Context(), tt.args.res, got)
if tt.wantErr != "" {
assert.ErrorContains(t, err, tt.wantErr)
return

View File

@@ -84,10 +84,8 @@ func Test_image_ConfigNameWithCustomDockerHost(t *testing.T) {
var dockerHostParam string
if runtime.GOOS != "windows" {
runtimeDir, err := os.MkdirTemp("", "daemon")
dir, err := os.MkdirTemp("", "image") //nolint:usetesting // Too long file paths created by t.TempDir() cause an invalid argument error with socket binding
require.NoError(t, err)
dir := filepath.Join(runtimeDir, "image")
err = os.MkdirAll(dir, os.ModePerm)
require.NoError(t, err)
@@ -130,10 +128,8 @@ func Test_image_ConfigNameWithCustomPodmanHost(t *testing.T) {
},
}
runtimeDir, err := os.MkdirTemp("", "daemon")
dir, err := os.MkdirTemp("", "image") //nolint:usetesting // Too long file paths created by t.TempDir() cause an invalid argument error with socket binding
require.NoError(t, err)
dir := filepath.Join(runtimeDir, "image")
err = os.MkdirAll(dir, os.ModePerm)
require.NoError(t, err)

View File

@@ -19,13 +19,12 @@ import (
func setupPodmanSock(t *testing.T) *httptest.Server {
t.Helper()
runtimeDir, err := os.MkdirTemp("", "daemon")
require.NoError(t, err)
runtimeDir := t.TempDir()
t.Setenv("XDG_RUNTIME_DIR", runtimeDir)
dir := filepath.Join(runtimeDir, "podman")
err = os.MkdirAll(dir, os.ModePerm)
err := os.MkdirAll(dir, os.ModePerm)
require.NoError(t, err)
sockPath := filepath.Join(dir, "podman.sock")

View File

@@ -1,7 +1,6 @@
package image
import (
"context"
"fmt"
"net/http/httptest"
"testing"
@@ -275,7 +274,7 @@ func TestNewDockerImage(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.args.option.ImageSources = types.AllImageSources
img, cleanup, err := NewContainerImage(context.Background(), tt.args.imageName, tt.args.option)
img, cleanup, err := NewContainerImage(t.Context(), tt.args.imageName, tt.args.option)
defer cleanup()
if tt.wantErr {
@@ -393,7 +392,7 @@ func TestNewDockerImageWithPrivateRegistry(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.args.option.ImageSources = types.AllImageSources
_, cleanup, err := NewContainerImage(context.Background(), tt.args.imageName, tt.args.option)
_, cleanup, err := NewContainerImage(t.Context(), tt.args.imageName, tt.args.option)
defer cleanup()
if tt.wantErr != "" {
@@ -542,7 +541,7 @@ func TestDockerPlatformArguments(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
imageName := fmt.Sprintf("%s/library/alpine:3.10", serverAddr)
tt.args.option.ImageSources = types.AllImageSources
_, cleanup, err := NewContainerImage(context.Background(), imageName, tt.args.option)
_, cleanup, err := NewContainerImage(t.Context(), imageName, tt.args.option)
defer cleanup()
if tt.wantErr != "" {

View File

@@ -151,7 +151,7 @@ func TestECRGetCredential(t *testing.T) {
e := ECRClient{
Client: mockedECR{Resp: c.Resp},
}
username, password, err := e.GetCredential(context.Background())
username, password, err := e.GetCredential(t.Context())
if err != nil {
t.Fatalf("%d, unexpected error", err)
}

View File

@@ -1,7 +1,6 @@
package registry
import (
"context"
"testing"
"github.com/google/go-containerregistry/pkg/authn"
@@ -30,7 +29,7 @@ func TestGetToken(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotAuth := GetToken(context.Background(), tt.args.domain, tt.args.opt)
gotAuth := GetToken(t.Context(), tt.args.domain, tt.args.opt)
assert.Equal(t, tt.wantAuth, gotAuth)
})
}

View File

@@ -1,7 +1,6 @@
package testutil
import (
"context"
"testing"
"github.com/stretchr/testify/require"
@@ -17,7 +16,7 @@ func AdaptAndCompare[T any](t *testing.T, source string, expected any, fn adaptF
"main.yaml": source,
})
fctx, err := parser.New().ParseFile(context.TODO(), fsys, "main.yaml")
fctx, err := parser.New().ParseFile(t.Context(), fsys, "main.yaml")
require.NoError(t, err)
adapted := fn(*fctx)

View File

@@ -1,7 +1,6 @@
package tftestutil
import (
"context"
"testing"
"github.com/aquasecurity/trivy/internal/testutil"
@@ -14,10 +13,10 @@ func CreateModulesFromSource(t *testing.T, source, ext string) terraform.Modules
"source" + ext: source,
})
p := parser.New(fs, "", parser.OptionStopOnHCLError(true))
if err := p.ParseFS(context.TODO(), "."); err != nil {
if err := p.ParseFS(t.Context(), "."); err != nil {
t.Fatal(err)
}
modules, _, err := p.EvaluateAll(context.TODO())
modules, _, err := p.EvaluateAll(t.Context())
if err != nil {
t.Fatalf("parse error: %s", err)
}

View File

@@ -2,7 +2,6 @@ package rego_test
import (
"bytes"
"context"
"io/fs"
"os"
"path/filepath"
@@ -48,7 +47,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -81,7 +80,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -113,7 +112,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": false,
@@ -148,7 +147,7 @@ deny_evil {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -178,7 +177,7 @@ deny[msg] {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -215,7 +214,7 @@ deny[res] {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -256,7 +255,7 @@ deny[res] {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -309,7 +308,7 @@ deny[res] {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -357,7 +356,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -390,7 +389,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -420,7 +419,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -455,7 +454,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -489,7 +488,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"evil": true,
@@ -526,7 +525,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"text": "dynamic",
@@ -558,7 +557,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"text": "test",
@@ -605,7 +604,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"text": "test",
@@ -719,7 +718,7 @@ deny {
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{})
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{})
require.NoError(t, err)
assert.Len(t, results.GetFailed(), 1)
@@ -758,7 +757,7 @@ deny {
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{})
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{})
require.NoError(t, err)
assert.Len(t, results.GetFailed(), 1)
@@ -789,7 +788,7 @@ deny {
rego.WithPolicyDirs("checks"),
)
require.NoError(t, scanner.LoadPolicies(fsys))
_, err := scanner.ScanInput(context.TODO(), types.SourceYAML, rego.Input{})
_, err := scanner.ScanInput(t.Context(), types.SourceYAML, rego.Input{})
require.NoError(t, err)
}
@@ -853,7 +852,7 @@ deny {
scanner := rego.NewScanner(rego.WithPolicyDirs("policies"))
require.NoError(t, scanner.LoadPolicies(srcFS))
results, err := scanner.ScanInput(context.TODO(), types.SourceJSON, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceJSON, rego.Input{
Path: "/evil.lol",
Contents: map[string]any{
"text": "test",
@@ -924,7 +923,7 @@ deny {
require.NoError(t, scanner.LoadPolicies(nil))
results, err := scanner.ScanInput(context.TODO(), types.SourceYAML, rego.Input{
results, err := scanner.ScanInput(t.Context(), types.SourceYAML, rego.Input{
Path: "test.yaml",
Contents: map[string]any{"service": "test"},
})
@@ -1009,7 +1008,7 @@ deny {
)
require.NoError(t, scanner.LoadPolicies(nil))
results, err := scanner.ScanInput(context.TODO(), types.SourceYAML, rego.Input{})
results, err := scanner.ScanInput(t.Context(), types.SourceYAML, rego.Input{})
require.NoError(t, err)
require.Equal(t, tt.expected, len(results.GetFailed()) > 0)

View File

@@ -1,7 +1,6 @@
package parser
import (
"context"
"io/fs"
"testing"
@@ -204,7 +203,7 @@ func TestParser_Parse(t *testing.T) {
require.NoError(t, targetFS.WriteFile(filename, []byte(tt.input), 0644))
p := New(targetFS)
got, err := p.ParseFS(context.Background(), ".")
got, err := p.ParseFS(t.Context(), ".")
require.NoError(t, err)
if !tt.wantDeployment {
@@ -292,7 +291,7 @@ func Test_NestedResourceParsing(t *testing.T) {
require.NoError(t, targetFS.WriteFile("nested.json", []byte(input), 0644))
p := New(targetFS)
got, err := p.ParseFS(context.Background(), ".")
got, err := p.ParseFS(t.Context(), ".")
require.NoError(t, err)
require.Len(t, got, 1)

View File

@@ -1,7 +1,6 @@
package parser
import (
"context"
"os"
"path/filepath"
"strings"
@@ -14,12 +13,10 @@ import (
)
func parseFile(t *testing.T, source, name string) (FileContexts, error) {
tmp, err := os.MkdirTemp(os.TempDir(), "defsec")
require.NoError(t, err)
defer func() { _ = os.RemoveAll(tmp) }()
tmp := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(tmp, name), []byte(source), 0600))
fs := os.DirFS(tmp)
return New().ParseFS(context.TODO(), fs, ".")
return New().ParseFS(t.Context(), fs, ".")
}
func Test_parse_yaml(t *testing.T) {
@@ -252,7 +249,7 @@ Resources:
}
p := New(WithParameters(params))
files, err := p.ParseFS(context.TODO(), fs, ".")
files, err := p.ParseFS(t.Context(), fs, ".")
require.NoError(t, err)
require.Len(t, files, 1)
@@ -289,7 +286,7 @@ Resources:
p := New(WithParameterFiles("params.json"))
files, err := p.ParseFS(context.TODO(), fs, ".")
files, err := p.ParseFS(t.Context(), fs, ".")
require.NoError(t, err)
require.Len(t, files, 1)
@@ -349,7 +346,7 @@ Resources:
WithConfigsFS(configFS),
)
files, err := p.ParseFS(context.TODO(), fs, ".")
files, err := p.ParseFS(t.Context(), fs, ".")
require.NoError(t, err)
require.Len(t, files, 2)
@@ -402,7 +399,7 @@ func TestJsonWithNumbers(t *testing.T) {
"main.json": src,
})
files, err := New().ParseFS(context.TODO(), fsys, ".")
files, err := New().ParseFS(t.Context(), fsys, ".")
require.NoError(t, err)
require.Len(t, files, 1)
@@ -436,7 +433,7 @@ Conditions:
"main.yaml": src,
})
files, err := New().ParseFS(context.TODO(), fsys, ".")
files, err := New().ParseFS(t.Context(), fsys, ".")
require.NoError(t, err)
require.Len(t, files, 1)
}
@@ -453,7 +450,7 @@ Resources:
"main.yaml": src,
})
files, err := New().ParseFS(context.TODO(), fsys, ".")
files, err := New().ParseFS(t.Context(), fsys, ".")
require.NoError(t, err)
require.Len(t, files, 1)
@@ -479,7 +476,7 @@ Resources:
"main.yaml": src,
})
files, err := New().ParseFS(context.TODO(), fsys, ".")
files, err := New().ParseFS(t.Context(), fsys, ".")
require.NoError(t, err)
require.Len(t, files, 1)

View File

@@ -1,7 +1,6 @@
package cloudformation
import (
"context"
"strings"
"testing"
@@ -59,7 +58,7 @@ deny[res] {
scanner := New(rego.WithPolicyDirs("rules"))
results, err := scanner.ScanFS(context.TODO(), fs, "code")
results, err := scanner.ScanFS(t.Context(), fs, "code")
require.NoError(t, err)
require.Len(t, results.GetFailed(), 1)
@@ -216,7 +215,7 @@ Resources:
rego.WithPolicyNamespaces("user"),
)
results, err := scanner.ScanFS(context.TODO(), fsys, "code")
results, err := scanner.ScanFS(t.Context(), fsys, "code")
require.NoError(t, err)
if tt.ignored == 0 {

View File

@@ -1,7 +1,6 @@
package test
import (
"context"
"os"
"testing"
@@ -15,7 +14,7 @@ import (
func Test_basic_cloudformation_scanning(t *testing.T) {
cfScanner := cloudformation.New(rego.WithEmbeddedPolicies(true), rego.WithEmbeddedLibraries(true))
results, err := cfScanner.ScanFS(context.TODO(), os.DirFS("./examples/bucket"), ".")
results, err := cfScanner.ScanFS(t.Context(), os.DirFS("./examples/bucket"), ".")
require.NoError(t, err)
assert.NotEmpty(t, results.GetFailed())
@@ -24,7 +23,7 @@ func Test_basic_cloudformation_scanning(t *testing.T) {
func Test_cloudformation_scanning_has_expected_errors(t *testing.T) {
cfScanner := cloudformation.New(rego.WithEmbeddedPolicies(true), rego.WithEmbeddedLibraries(true))
results, err := cfScanner.ScanFS(context.TODO(), os.DirFS("./examples/bucket"), ".")
results, err := cfScanner.ScanFS(t.Context(), os.DirFS("./examples/bucket"), ".")
require.NoError(t, err)
assert.NotEmpty(t, results.GetFailed())

View File

@@ -1,7 +1,6 @@
package parser_test
import (
"context"
"strings"
"testing"
@@ -19,7 +18,7 @@ RUN make /app
CMD python /app/app.py
`
res, err := parser.Parse(context.TODO(), strings.NewReader(input), "Dockerfile")
res, err := parser.Parse(t.Context(), strings.NewReader(input), "Dockerfile")
require.NoError(t, err)
df, ok := res.(*dockerfile.Dockerfile)
@@ -103,7 +102,7 @@ EOF`,
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
res, err := parser.Parse(context.TODO(), strings.NewReader(tt.src), "Dockerfile")
res, err := parser.Parse(t.Context(), strings.NewReader(tt.src), "Dockerfile")
require.NoError(t, err)
df, ok := res.(*dockerfile.Dockerfile)

View File

@@ -2,7 +2,6 @@ package dockerfile_test
import (
"bytes"
"context"
"strings"
"testing"
"testing/fstest"
@@ -224,7 +223,7 @@ USER root
scanner := dockerfile.NewScanner(rego.WithPolicyDirs("rules"))
results, err := scanner.ScanFS(context.TODO(), fs, "code")
results, err := scanner.ScanFS(t.Context(), fs, "code")
require.NoError(t, err)
require.Len(t, results.GetFailed(), 1)
@@ -571,7 +570,7 @@ COPY --from=dep /binary /`
rego.WithRegoErrorLimits(0),
)
results, err := scanner.ScanFS(context.TODO(), fsys, "code")
results, err := scanner.ScanFS(t.Context(), fsys, "code")
if tc.expectedError != "" && err != nil {
require.Equal(t, tc.expectedError, err.Error(), tc.name)
} else {
@@ -692,7 +691,7 @@ deny contains res if {
rego.WithEmbeddedLibraries(true),
rego.WithRegoErrorLimits(0),
)
results, err := scanner.ScanFS(context.TODO(), fsys, ".")
results, err := scanner.ScanFS(t.Context(), fsys, ".")
require.NoError(t, err)
if tt.expected {
testutil.AssertRuleFound(t, "dockerfile-general-maintainer-deprecated", results, "")

View File

@@ -1,7 +1,6 @@
package generic_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
@@ -50,7 +49,7 @@ deny[res] {
scanner := generic.NewJsonScanner(rego.WithPolicyDirs("rules"))
results, err := scanner.ScanFS(context.TODO(), fsys, "code")
results, err := scanner.ScanFS(t.Context(), fsys, "code")
require.NoError(t, err)
require.Len(t, results.GetFailed(), 1)
@@ -119,7 +118,7 @@ deny[res] {
scanner := generic.NewYamlScanner(rego.WithPolicyDirs("rules"))
results, err := scanner.ScanFS(context.TODO(), fsys, "code")
results, err := scanner.ScanFS(t.Context(), fsys, "code")
require.NoError(t, err)
require.Len(t, results.GetFailed(), 1)
@@ -187,7 +186,7 @@ deny[res] {
scanner := generic.NewTomlScanner(rego.WithPolicyDirs("rules"))
results, err := scanner.ScanFS(context.TODO(), fsys, "code")
results, err := scanner.ScanFS(t.Context(), fsys, "code")
require.NoError(t, err)
require.Len(t, results.GetFailed(), 1)

View File

@@ -1,7 +1,6 @@
package parser
import (
"context"
"os"
"path/filepath"
"testing"
@@ -14,7 +13,7 @@ func TestParseFS(t *testing.T) {
t.Run("source chart is located next to an same archived chart", func(t *testing.T) {
p, err := New(".")
require.NoError(t, err)
require.NoError(t, p.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", "chart-and-archived-chart")), "."))
require.NoError(t, p.ParseFS(t.Context(), os.DirFS(filepath.Join("testdata", "chart-and-archived-chart")), "."))
expectedFiles := []string{
"my-chart/Chart.yaml",
@@ -36,7 +35,7 @@ func TestParseFS(t *testing.T) {
require.NoError(t, err)
fsys := os.DirFS(filepath.Join("testdata", "archive-with-symlinks"))
require.NoError(t, p.ParseFS(context.TODO(), fsys, "chart.tar.gz"))
require.NoError(t, p.ParseFS(t.Context(), fsys, "chart.tar.gz"))
expectedFiles := []string{
"chart/Chart.yaml",
@@ -54,7 +53,7 @@ func TestParseFS(t *testing.T) {
require.NoError(t, err)
fsys := os.DirFS(filepath.Join("testdata", "multiple-archived-deps"))
require.NoError(t, p.ParseFS(context.TODO(), fsys, "."))
require.NoError(t, p.ParseFS(t.Context(), fsys, "."))
expectedFiles := []string{
"Chart.yaml",
@@ -69,7 +68,7 @@ func TestParseFS(t *testing.T) {
require.NoError(t, err)
fsys := os.DirFS(filepath.Join("testdata", "non-deps-archives"))
require.NoError(t, p.ParseFS(context.TODO(), fsys, "."))
require.NoError(t, p.ParseFS(t.Context(), fsys, "."))
expectedFiles := []string{
"Chart.yaml",

View File

@@ -1,7 +1,6 @@
package test
import (
"context"
"os"
"path/filepath"
"strings"
@@ -41,7 +40,7 @@ func Test_helm_parser_with_options_with_values_file(t *testing.T) {
helmParser, err := parser.New(chartName, opts...)
require.NoError(t, err)
require.NoError(t, helmParser.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", chartName)), "."))
require.NoError(t, helmParser.ParseFS(t.Context(), os.DirFS(filepath.Join("testdata", chartName)), "."))
manifests, err := helmParser.RenderedChartFiles()
require.NoError(t, err)
@@ -95,7 +94,7 @@ func Test_helm_parser_with_options_with_set_value(t *testing.T) {
helmParser, err := parser.New(chartName, opts...)
require.NoError(t, err)
err = helmParser.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", chartName)), ".")
err = helmParser.ParseFS(t.Context(), os.DirFS(filepath.Join("testdata", chartName)), ".")
require.NoError(t, err)
manifests, err := helmParser.RenderedChartFiles()
require.NoError(t, err)
@@ -145,7 +144,7 @@ func Test_helm_parser_with_options_with_api_versions(t *testing.T) {
helmParser, err := parser.New(chartName, opts...)
require.NoError(t, err)
err = helmParser.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", chartName)), ".")
err = helmParser.ParseFS(t.Context(), os.DirFS(filepath.Join("testdata", chartName)), ".")
require.NoError(t, err)
manifests, err := helmParser.RenderedChartFiles()
require.NoError(t, err)
@@ -204,7 +203,7 @@ func Test_helm_parser_with_options_with_kube_versions(t *testing.T) {
return
}
require.NoError(t, err)
require.NoError(t, helmParser.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", chartName)), "."))
require.NoError(t, helmParser.ParseFS(t.Context(), os.DirFS(filepath.Join("testdata", chartName)), "."))
manifests, err := helmParser.RenderedChartFiles()
require.NoError(t, err)

View File

@@ -1,7 +1,6 @@
package test
import (
"context"
"os"
"path/filepath"
"strings"
@@ -35,7 +34,7 @@ func Test_helm_parser(t *testing.T) {
chartName := test.chartName
helmParser, err := parser.New(chartName)
require.NoError(t, err)
require.NoError(t, helmParser.ParseFS(context.TODO(), os.DirFS("testdata"), chartName))
require.NoError(t, helmParser.ParseFS(t.Context(), os.DirFS("testdata"), chartName))
manifests, err := helmParser.RenderedChartFiles()
require.NoError(t, err)
@@ -73,7 +72,7 @@ func Test_helm_parser_where_name_non_string(t *testing.T) {
helmParser, err := parser.New(chartName)
require.NoError(t, err)
require.NoError(t, helmParser.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", chartName)), "."))
require.NoError(t, helmParser.ParseFS(t.Context(), os.DirFS(filepath.Join("testdata", chartName)), "."))
}
}
@@ -161,7 +160,7 @@ func Test_helm_tarball_parser(t *testing.T) {
helmParser, err := parser.New(test.archiveFile)
require.NoError(t, err)
require.NoError(t, helmParser.ParseFS(context.TODO(), testFs, "."))
require.NoError(t, helmParser.ParseFS(t.Context(), testFs, "."))
manifests, err := helmParser.RenderedChartFiles()
require.NoError(t, err)

Some files were not shown because too many files have changed in this diff Show More