test: include integration tests in linting and fix all issues (#9060)

This commit is contained in:
Teppei Fukuda
2025-06-24 17:09:15 +04:00
committed by GitHub
parent 6bf7ac41fb
commit cd7c595e4a
14 changed files with 207 additions and 223 deletions

View File

@@ -3,15 +3,14 @@
package integration
import (
"context"
"os"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/aquasecurity/trivy/internal/testutil"
"github.com/aquasecurity/trivy/pkg/types"
"github.com/stretchr/testify/require"
)
func TestDockerEngine(t *testing.T) {
@@ -216,7 +215,7 @@ func TestDockerEngine(t *testing.T) {
// Set a temp dir so that modules will not be loaded
t.Setenv("XDG_DATA_HOME", cacheDir)
ctx := context.Background()
ctx := t.Context()
defer ctx.Done()
cli := testutil.NewDockerClient(t)
@@ -272,7 +271,7 @@ func TestDockerEngine(t *testing.T) {
}
if len(tt.ignoreIDs) != 0 {
trivyIgnore := ".trivyignore"
err := os.WriteFile(trivyIgnore, []byte(strings.Join(tt.ignoreIDs, "\n")), 0444)
err := os.WriteFile(trivyIgnore, []byte(strings.Join(tt.ignoreIDs, "\n")), 0o444)
require.NoError(t, err, "failed to write .trivyignore")
defer os.Remove(trivyIgnore)
}