From 7b910ab0a4614c04e8207758136655a438beb42e Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Thu, 1 Jan 2026 17:20:19 +0200 Subject: [PATCH 1/3] fix incorrect tests names --- scanpullrequest/scanpullrequest_test.go | 4 ++-- utils/getconfiguration_test.go | 4 ++-- utils/issues/issuescollection_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scanpullrequest/scanpullrequest_test.go b/scanpullrequest/scanpullrequest_test.go index 5dc8e7ee5..d330a3b09 100644 --- a/scanpullrequest/scanpullrequest_test.go +++ b/scanpullrequest/scanpullrequest_test.go @@ -296,7 +296,7 @@ func prepareConfigAndClient(t *testing.T, xrayVersion, xscVersion string, server return repository, client } -func TestDeletePreviousPullRequestMessages(t *testing.T) { +func TestDeleteExistingPullRequestComments(t *testing.T) { repository := &utils.Repository{ Params: utils.Params{ Git: utils.Git{ @@ -345,7 +345,7 @@ func TestDeletePreviousPullRequestMessages(t *testing.T) { } } -func TestDeletePreviousPullRequestReviewMessages(t *testing.T) { +func TestDeleteExistingPullRequestReviewComments(t *testing.T) { repository := &utils.Repository{ Params: utils.Params{ Git: utils.Git{ diff --git a/utils/getconfiguration_test.go b/utils/getconfiguration_test.go index 9d7e489b6..b034f6080 100644 --- a/utils/getconfiguration_test.go +++ b/utils/getconfiguration_test.go @@ -25,7 +25,7 @@ var ( configProfileFile = filepath.Join("..", "testdata", "configprofile", "configProfileExample.json") ) -func TestExtractParamsFromEnvError(t *testing.T) { +func TestExtractJFrogCredentialsFromEnvs(t *testing.T) { SetEnvAndAssert(t, map[string]string{ JFrogUrlEnv: "", JFrogTokenEnv: "", @@ -124,7 +124,7 @@ func TestExtractVcsProviderFromEnv(t *testing.T) { assert.Equal(t, vcsutils.AzureRepos, vcsProvider) } -func TestExtractClientInfo(t *testing.T) { +func TestExtractGitParamsFromEnvs(t *testing.T) { defer func() { assert.NoError(t, SanitizeEnv()) }() diff --git a/utils/issues/issuescollection_test.go b/utils/issues/issuescollection_test.go index b53f7b833..ab9a857e5 100644 --- a/utils/issues/issuescollection_test.go +++ b/utils/issues/issuescollection_test.go @@ -149,7 +149,7 @@ func getTestData() ScansIssuesCollection { return issuesCollection } -func TestCountIssuesCollectionFindings(t *testing.T) { +func TestGetAllIssuesCount(t *testing.T) { testCases := []struct { name string includeSecrets bool From 992e1a03160e1f9430718a1052df0468251cb5fc Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Thu, 1 Jan 2026 17:39:06 +0200 Subject: [PATCH 2/3] rename TestFixVersionInfo_UpdateFixVersionIfMax to TestUpdateFixVersionIfMax and place it in the correct testfile --- packagehandlers/packagehandlers_test.go | 21 --------------------- utils/utils_test.go | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/packagehandlers/packagehandlers_test.go b/packagehandlers/packagehandlers_test.go index 0034c29a0..c50aacac4 100644 --- a/packagehandlers/packagehandlers_test.go +++ b/packagehandlers/packagehandlers_test.go @@ -596,27 +596,6 @@ func TestGetProjectPoms(t *testing.T) { assert.Len(t, mvnHandler.pomPaths, 2) } -// General Utils functions -func TestFixVersionInfo_UpdateFixVersionIfMax(t *testing.T) { - type testCase struct { - fixVersionInfo utils.VulnerabilityDetails - newFixVersion string - expectedOutput string - } - - testCases := []testCase{ - {fixVersionInfo: utils.VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.2.4", expectedOutput: "1.2.4"}, - {fixVersionInfo: utils.VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.0.4", expectedOutput: "1.2.3"}, - } - - for _, tc := range testCases { - t.Run(tc.expectedOutput, func(t *testing.T) { - tc.fixVersionInfo.UpdateFixVersionIfMax(tc.newFixVersion) - assert.Equal(t, tc.expectedOutput, tc.fixVersionInfo.SuggestedFixedVersion) - }) - } -} - func TestUpdatePackageVersion(t *testing.T) { testProjectPath := filepath.Join("..", "testdata", "packagehandlers") currDir, err := os.Getwd() diff --git a/utils/utils_test.go b/utils/utils_test.go index c179e1a3d..961f87d68 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -484,6 +484,26 @@ func TestUploadSbomSnapshotToGithubDependencyGraph(t *testing.T) { } } +func TestUpdateFixVersionIfMax(t *testing.T) { + type testCase struct { + fixVersionInfo VulnerabilityDetails + newFixVersion string + expectedOutput string + } + + testCases := []testCase{ + {fixVersionInfo: VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.2.4", expectedOutput: "1.2.4"}, + {fixVersionInfo: VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.0.4", expectedOutput: "1.2.3"}, + } + + for _, tc := range testCases { + t.Run(tc.expectedOutput, func(t *testing.T) { + tc.fixVersionInfo.UpdateFixVersionIfMax(tc.newFixVersion) + assert.Equal(t, tc.expectedOutput, tc.fixVersionInfo.SuggestedFixedVersion) + }) + } +} + func createTestSecurityCommandResults() *results.SecurityCommandResults { // Create a simple BOM with components components := []cyclonedx.Component{ From 550aa8e0cb42372f5181917f044eb9abf5008c46 Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Thu, 1 Jan 2026 17:58:26 +0200 Subject: [PATCH 3/3] rename --- utils/analytics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/analytics_test.go b/utils/analytics_test.go index 7253c5dea..9cc34cdd0 100644 --- a/utils/analytics_test.go +++ b/utils/analytics_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestCreateAnalyticsGeneralEvent(t *testing.T) { +func TestCreateScanEvent(t *testing.T) { gitInfoContext := &xscservices.XscGitInfoContext{ Source: xscservices.CommitContext{ GitRepoHttpsCloneUrl: "http://localhost:8080/my-user/my-project.git",