Skip to content

Commit 164a9c1

Browse files
authored
Renaming tests to match new functions names (#1020)
1 parent 8544f45 commit 164a9c1

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

packagehandlers/packagehandlers_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -596,27 +596,6 @@ func TestGetProjectPoms(t *testing.T) {
596596
assert.Len(t, mvnHandler.pomPaths, 2)
597597
}
598598

599-
// General Utils functions
600-
func TestFixVersionInfo_UpdateFixVersionIfMax(t *testing.T) {
601-
type testCase struct {
602-
fixVersionInfo utils.VulnerabilityDetails
603-
newFixVersion string
604-
expectedOutput string
605-
}
606-
607-
testCases := []testCase{
608-
{fixVersionInfo: utils.VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.2.4", expectedOutput: "1.2.4"},
609-
{fixVersionInfo: utils.VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.0.4", expectedOutput: "1.2.3"},
610-
}
611-
612-
for _, tc := range testCases {
613-
t.Run(tc.expectedOutput, func(t *testing.T) {
614-
tc.fixVersionInfo.UpdateFixVersionIfMax(tc.newFixVersion)
615-
assert.Equal(t, tc.expectedOutput, tc.fixVersionInfo.SuggestedFixedVersion)
616-
})
617-
}
618-
}
619-
620599
func TestUpdatePackageVersion(t *testing.T) {
621600
testProjectPath := filepath.Join("..", "testdata", "packagehandlers")
622601
currDir, err := os.Getwd()

scanpullrequest/scanpullrequest_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func prepareConfigAndClient(t *testing.T, xrayVersion, xscVersion string, server
296296
return repository, client
297297
}
298298

299-
func TestDeletePreviousPullRequestMessages(t *testing.T) {
299+
func TestDeleteExistingPullRequestComments(t *testing.T) {
300300
repository := &utils.Repository{
301301
Params: utils.Params{
302302
Git: utils.Git{
@@ -345,7 +345,7 @@ func TestDeletePreviousPullRequestMessages(t *testing.T) {
345345
}
346346
}
347347

348-
func TestDeletePreviousPullRequestReviewMessages(t *testing.T) {
348+
func TestDeleteExistingPullRequestReviewComments(t *testing.T) {
349349
repository := &utils.Repository{
350350
Params: utils.Params{
351351
Git: utils.Git{

utils/analytics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/stretchr/testify/assert"
99
)
1010

11-
func TestCreateAnalyticsGeneralEvent(t *testing.T) {
11+
func TestCreateScanEvent(t *testing.T) {
1212
gitInfoContext := &xscservices.XscGitInfoContext{
1313
Source: xscservices.CommitContext{
1414
GitRepoHttpsCloneUrl: "http://localhost:8080/my-user/my-project.git",

utils/getconfiguration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
configProfileFile = filepath.Join("..", "testdata", "configprofile", "configProfileExample.json")
2626
)
2727

28-
func TestExtractParamsFromEnvError(t *testing.T) {
28+
func TestExtractJFrogCredentialsFromEnvs(t *testing.T) {
2929
SetEnvAndAssert(t, map[string]string{
3030
JFrogUrlEnv: "",
3131
JFrogTokenEnv: "",
@@ -124,7 +124,7 @@ func TestExtractVcsProviderFromEnv(t *testing.T) {
124124
assert.Equal(t, vcsutils.AzureRepos, vcsProvider)
125125
}
126126

127-
func TestExtractClientInfo(t *testing.T) {
127+
func TestExtractGitParamsFromEnvs(t *testing.T) {
128128
defer func() {
129129
assert.NoError(t, SanitizeEnv())
130130
}()

utils/issues/issuescollection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func getTestData() ScansIssuesCollection {
149149
return issuesCollection
150150
}
151151

152-
func TestCountIssuesCollectionFindings(t *testing.T) {
152+
func TestGetAllIssuesCount(t *testing.T) {
153153
testCases := []struct {
154154
name string
155155
includeSecrets bool

utils/utils_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,26 @@ func TestUploadSbomSnapshotToGithubDependencyGraph(t *testing.T) {
484484
}
485485
}
486486

487+
func TestUpdateFixVersionIfMax(t *testing.T) {
488+
type testCase struct {
489+
fixVersionInfo VulnerabilityDetails
490+
newFixVersion string
491+
expectedOutput string
492+
}
493+
494+
testCases := []testCase{
495+
{fixVersionInfo: VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.2.4", expectedOutput: "1.2.4"},
496+
{fixVersionInfo: VulnerabilityDetails{SuggestedFixedVersion: "1.2.3", IsDirectDependency: true}, newFixVersion: "1.0.4", expectedOutput: "1.2.3"},
497+
}
498+
499+
for _, tc := range testCases {
500+
t.Run(tc.expectedOutput, func(t *testing.T) {
501+
tc.fixVersionInfo.UpdateFixVersionIfMax(tc.newFixVersion)
502+
assert.Equal(t, tc.expectedOutput, tc.fixVersionInfo.SuggestedFixedVersion)
503+
})
504+
}
505+
}
506+
487507
func createTestSecurityCommandResults() *results.SecurityCommandResults {
488508
// Create a simple BOM with components
489509
components := []cyclonedx.Component{

0 commit comments

Comments
 (0)