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

test(k8s): improve testing for k8s scanner #7769

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 4 additions & 3 deletions pkg/k8s/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ import (
)

func TestScanner_Scan(t *testing.T) {
flagOpts := flag.Options{ReportOptions: flag.ReportOptions{Format: "cyclonedx"}}
tests := []struct {
name string
clusterName string
opts flag.Options
artifacts []*artifacts.Artifact
wantComponents []*core.Component
}{
{
name: "test cluster info with resources",
clusterName: "test-cluster",
opts: flag.Options{ReportOptions: flag.ReportOptions{Format: "cyclonedx"}},
artifacts: []*artifacts.Artifact{
{
Namespace: "kube-system",
Expand Down Expand Up @@ -277,10 +278,10 @@ func TestScanner_Scan(t *testing.T) {
ctx := context.Background()
uuid.SetFakeUUID(t, "3ff14136-e09f-4df9-80ea-%012d")

runner, err := cmd.NewRunner(ctx, flagOpts)
runner, err := cmd.NewRunner(ctx, tt.opts)
require.NoError(t, err)

scanner := NewScanner(tt.clusterName, runner, flagOpts)
scanner := NewScanner(tt.clusterName, runner, tt.opts)
got, err := scanner.Scan(ctx, tt.artifacts)
require.NoError(t, err)

Expand Down