Skip to content

Commit c74376f

Browse files
Fixed review constant mapping
1 parent aa6ed6f commit c74376f

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

internal/constants/errors/errors.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ const (
2424
NoASCALicense = "User doesn't have \"AI Protection\" or \"Checkmarx One Assist\" license"
2525
FailedUploadFileMsgWithDomain = "Unable to upload the file to the pre-signed URL. Try adding the domain: %s to your allow list."
2626
FailedUploadFileMsgWithURL = "Unable to upload the file to the pre-signed URL. Try adding the URL: %s to your allow list."
27+
NoPermissionToUpdateApplication = "you do not have permission to update the application"
28+
FailedToUpdateApplication = "failed to update application"
29+
ApplicationNotFound = "Application not found"
2730

2831
// asca Engine
2932
FileExtensionIsRequired = "file must have an extension"
3033

3134
// Realtime
32-
RealtimeEngineErrFormat = "realtime engine error: %s"
33-
RealtimeEngineNotAvailable = "Realtime engine is not available for this tenant"
34-
RealtimeEngineFilePathRequired = "file path is required for realtime scan"
35-
NoPermissionToUpdateApplication = "you do not have permission to update the application"
35+
RealtimeEngineErrFormat = "realtime engine error: %s"
36+
RealtimeEngineNotAvailable = "Realtime engine is not available for this tenant"
37+
RealtimeEngineFilePathRequired = "file path is required for realtime scan"
3638
)
3739

3840
type RealtimeEngineError struct {

internal/services/applications.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func findApplicationAndUpdate(applicationName string, applicationsWrapper wrappe
7474
return errors.Wrapf(err, "%s:%s", errorConstants.FailedToGetApplication, applicationName)
7575
}
7676
if applicationResp == nil {
77-
return errors.Errorf("Application not found: %s", applicationName)
77+
return errors.Errorf("%s: %s", errorConstants.ApplicationNotFound, applicationName)
7878
}
7979
var applicationModel wrappers.ApplicationConfiguration
8080
var newApplicationRule wrappers.Rule
@@ -101,7 +101,7 @@ func findApplicationAndUpdate(applicationName string, applicationsWrapper wrappe
101101
func updateApplication(applicationModel *wrappers.ApplicationConfiguration, applicationWrapper wrappers.ApplicationsWrapper, applicationID string) error {
102102
errorModel, err := applicationWrapper.Update(applicationID, applicationModel)
103103
if errorModel != nil {
104-
err = errors.Errorf(ErrorCodeFormat, "failed to update application", errorModel.Code, errorModel.Message)
104+
err = errors.Errorf(ErrorCodeFormat, errorConstants.FailedToUpdateApplication, errorModel.Code, errorModel.Message)
105105
}
106106
if errorModel == nil && err == nil {
107107
logger.PrintIfVerbose("Successfully updated the application")

test/integration/scan_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,17 +2710,3 @@ func TestCreateScanWithExistingProjectAnd_AssignApplication(t *testing.T) {
27102710
err, _ := executeCommand(t, args...)
27112711
assert.NilError(t, err, "Project should be assigned to application")
27122712
}
2713-
2714-
func TestCreateScanWithExistingProjectAnd_ApplicationNotFoundFailed(t *testing.T) {
2715-
_, projectName := createNewProject(t, nil, nil, GenerateRandomProjectNameForScan())
2716-
2717-
args := []string{
2718-
"scan", "create",
2719-
flag(params.ProjectName), projectName,
2720-
flag(params.BranchFlag), "dummy_branch",
2721-
flag(params.SourcesFlag), "data/sources-gitignore.zip",
2722-
flag(params.ApplicationName), "mock",
2723-
}
2724-
err, _ := executeCommand(t, args...)
2725-
assert.ErrorContains(t, err, "Application not found: mock")
2726-
}

0 commit comments

Comments
 (0)