From aa7eb8df30fbea87053fe18d4d464d1647ed3023 Mon Sep 17 00:00:00 2001 From: Ross Tannenbaum Date: Wed, 18 Oct 2023 09:59:01 -0700 Subject: [PATCH] e2e: improve logging (#1268) --- e2etests/grpc_full_test.go | 2 +- e2etests/sanity_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/e2etests/grpc_full_test.go b/e2etests/grpc_full_test.go index e64fc5910..3066c5e5e 100644 --- a/e2etests/grpc_full_test.go +++ b/e2etests/grpc_full_test.go @@ -93,7 +93,7 @@ func verifyImage(t *testing.T, imgScan *v1.Image, test testCase) { foundMatch = true checkGRPCMatch(t, expectedVuln, matchingVuln) } - assert.Truef(t, foundMatch, "Expected to find %s in scan results", expectedVuln.Name) + assert.Truef(t, foundMatch, "Expected to find %s in scan results\nFound the following: %s", expectedVuln.Name, matching.Vulnerabilities) } } // Check feature FixedBy, and provide the related vulnerability if they differ. diff --git a/e2etests/sanity_test.go b/e2etests/sanity_test.go index cd1e0c254..e05823091 100644 --- a/e2etests/sanity_test.go +++ b/e2etests/sanity_test.go @@ -93,12 +93,12 @@ func verifyImageHasExpectedFeatures(t *testing.T, client *client.Clairify, test feature.Executables = nil matching.Executables = nil + matchingBytes, _ := json.MarshalIndent(matching.Vulnerabilities, "", " ") if !test.onlyCheckSpecifiedVulns { if len(matching.Vulnerabilities) != len(feature.Vulnerabilities) { - matchingBytes, _ := json.MarshalIndent(matching.Vulnerabilities, "", " ") featureVulnsBytes, _ := json.MarshalIndent(feature.Vulnerabilities, "", " ") - fmt.Printf("Matching: %s\n", matchingBytes) - fmt.Printf("Expected Feature: %s\n", featureVulnsBytes) + fmt.Printf("Matching: %s\n", string(matchingBytes)) + fmt.Printf("Expected Feature: %s\n", string(featureVulnsBytes)) } require.Equal(t, len(feature.Vulnerabilities), len(matching.Vulnerabilities)) @@ -116,7 +116,7 @@ func verifyImageHasExpectedFeatures(t *testing.T, client *client.Clairify, test foundMatch = true checkMatch(t, test.source, expectedVuln, matchingVuln) } - assert.Truef(t, foundMatch, "Expected to find %s in scan results", expectedVuln.Name) + assert.Truef(t, foundMatch, "Expected to find %s in scan results\nFound the following: %s", expectedVuln.Name, string(matchingBytes)) } } feature.Vulnerabilities = nil