diff --git a/integration/client_server_test.go b/integration/client_server_test.go index 8a5b62f05054..4d5d799e4cee 100644 --- a/integration/client_server_test.go +++ b/integration/client_server_test.go @@ -39,10 +39,10 @@ type csArgs struct { func TestClientServer(t *testing.T) { tests := []struct { - name string - args csArgs - golden string - wantErr string + name string + args csArgs + golden string + override func(t *testing.T, want, got *types.Report) }{ { name: "alpine 3.9", @@ -270,6 +270,9 @@ func TestClientServer(t *testing.T) { Target: "https://github.com/knqyf263/trivy-ci-test", }, golden: "testdata/test-repo.json.golden", + override: func(t *testing.T, want, got *types.Report) { + want.ArtifactName = "https://github.com/knqyf263/trivy-ci-test" + }, }, } @@ -284,7 +287,7 @@ func TestClientServer(t *testing.T) { } runTest(t, osArgs, tt.golden, "", types.FormatJSON, runOptions{ - override: overrideUID, + override: overrideFuncs(overrideUID, tt.override), }) }) } diff --git a/integration/repo_test.go b/integration/repo_test.go index 00665f17ab8d..e11e5a21a8b4 100644 --- a/integration/repo_test.go +++ b/integration/repo_test.go @@ -234,6 +234,14 @@ func TestRepository(t *testing.T) { }, golden: "testdata/composer.lock.json.golden", }, + { + name: "multiple lockfiles", + args: args{ + scanner: types.VulnerabilityScanner, + input: "testdata/fixtures/repo/trivy-ci-test", + }, + golden: "testdata/test-repo.json.golden", + }, { name: "dockerfile", args: args{ diff --git a/integration/testdata/fixtures/repo/trivy-ci-test b/integration/testdata/fixtures/repo/trivy-ci-test new file mode 160000 index 000000000000..17728b280482 --- /dev/null +++ b/integration/testdata/fixtures/repo/trivy-ci-test @@ -0,0 +1 @@ +Subproject commit 17728b2804826b2af83160cde847d03a3c5737fd diff --git a/integration/testdata/test-repo.json.golden b/integration/testdata/test-repo.json.golden index 360ba1f3f097..07cb12e69eef 100644 --- a/integration/testdata/test-repo.json.golden +++ b/integration/testdata/test-repo.json.golden @@ -1,7 +1,7 @@ { "SchemaVersion": 2, "CreatedAt": "2021-08-25T12:20:30.000000005Z", - "ArtifactName": "https://github.com/knqyf263/trivy-ci-test", + "ArtifactName": "testdata/fixtures/repo/trivy-ci-test", "ArtifactType": "repository", "Metadata": { "ImageConfig": { @@ -109,6 +109,11 @@ "LastModifiedDate": "2021-08-16T16:37:00Z" } ] + }, + { + "Target": "Pipfile.lock", + "Class": "lang-pkgs", + "Type": "pipenv" } ] }