1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

chore(go): simplify code using gofmt -s (#2065)

This commit is contained in:
Christopher Fenner 2020-09-24 08:58:53 +02:00 committed by GitHub
parent b219fb6514
commit 6999380ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 107 additions and 109 deletions

View File

@ -325,12 +325,12 @@ func TestBuildATCCheckBody(t *testing.T) {
"",
ATCObjects{
Package: []Package{
Package{Name: "testPackage", IncludeSubpackages: true},
Package{Name: "testPackage2", IncludeSubpackages: false},
{Name: "testPackage", IncludeSubpackages: true},
{Name: "testPackage2", IncludeSubpackages: false},
},
SoftwareComponent: []SoftwareComponent{
SoftwareComponent{Name: "testSoftwareComponent"},
SoftwareComponent{Name: "testSoftwareComponent2"},
{Name: "testSoftwareComponent"},
{Name: "testSoftwareComponent2"},
},
},
}
@ -357,8 +357,8 @@ func TestBuildATCCheckBody(t *testing.T) {
"",
ATCObjects{
Package: []Package{
Package{Name: "testPackage", IncludeSubpackages: true},
Package{Name: "testPackage2", IncludeSubpackages: false},
{Name: "testPackage", IncludeSubpackages: true},
{Name: "testPackage2", IncludeSubpackages: false},
},
},
}
@ -386,8 +386,8 @@ func TestBuildATCCheckBody(t *testing.T) {
"",
ATCObjects{
SoftwareComponent: []SoftwareComponent{
SoftwareComponent{Name: "testSoftwareComponent"},
SoftwareComponent{Name: "testSoftwareComponent2"},
{Name: "testSoftwareComponent"},
{Name: "testSoftwareComponent2"},
},
},
}
@ -414,12 +414,12 @@ func TestBuildATCCheckBody(t *testing.T) {
"TestConfiguration",
ATCObjects{
SoftwareComponent: []SoftwareComponent{
SoftwareComponent{Name: "testSoftwareComponent"},
SoftwareComponent{Name: "testSoftwareComponent2"},
{Name: "testSoftwareComponent"},
{Name: "testSoftwareComponent2"},
},
Package: []Package{
Package{Name: "testPackage", IncludeSubpackages: true},
Package{Name: "testPackage2", IncludeSubpackages: false},
{Name: "testPackage", IncludeSubpackages: true},
{Name: "testPackage2", IncludeSubpackages: false},
},
},
}

View File

@ -171,7 +171,7 @@ func verifyCxProjectCompliance(config checkmarxExecuteScanOptions, sys checkmarx
xmlReportName := createReportName(workspace, "CxSASTResults_%v.xml")
results := getDetailedResults(sys, xmlReportName, scanID)
reports = append(reports, piperutils.Path{Target: xmlReportName})
links := []piperutils.Path{piperutils.Path{Target: results["DeepLink"].(string), Name: "Checkmarx Web UI"}}
links := []piperutils.Path{{Target: results["DeepLink"].(string), Name: "Checkmarx Web UI"}}
piperutils.PersistReportsAndLinks("checkmarxExecuteScan", workspace, reports, links)
reportToInflux(results, influx)

View File

@ -71,12 +71,12 @@ func (sys *systemMock) GetProjectByID(projectID int) (bool, checkmarx.Project) {
func (sys *systemMock) GetProjectsByNameAndTeam(projectName, teamID string) []checkmarx.Project {
if !sys.createProject || sys.previousPName == projectName {
if strings.Contains(projectName, "PR-17") {
return []checkmarx.Project{checkmarx.Project{ID: 17, Name: projectName, TeamID: teamID, IsPublic: true}}
return []checkmarx.Project{{ID: 17, Name: projectName, TeamID: teamID, IsPublic: true}}
}
return []checkmarx.Project{checkmarx.Project{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}}
return []checkmarx.Project{{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}}
}
if projectName == "Test" {
return []checkmarx.Project{checkmarx.Project{ID: 1, Name: projectName, TeamID: teamID, IsPublic: true}}
return []checkmarx.Project{{ID: 1, Name: projectName, TeamID: teamID, IsPublic: true}}
}
sys.previousPName = projectName
return []checkmarx.Project{}
@ -100,7 +100,7 @@ func (sys *systemMock) GetResults(scanID int) checkmarx.ResultsStatistics {
return checkmarx.ResultsStatistics{}
}
func (sys *systemMock) GetScans(projectID int) (bool, []checkmarx.ScanStatus) {
return true, []checkmarx.ScanStatus{checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: false}}
return true, []checkmarx.ScanStatus{{IsIncremental: true}, {IsIncremental: true}, {IsIncremental: true}, {IsIncremental: false}}
}
func (sys *systemMock) GetScanStatusAndDetail(scanID int) (string, checkmarx.ScanStatusDetail) {
return "Finished", checkmarx.ScanStatusDetail{Stage: "Step 1 of 25", Step: "Scan something"}
@ -127,13 +127,13 @@ func (sys *systemMock) CreateBranch(projectID int, branchName string) int {
return 18
}
func (sys *systemMock) GetPresets() []checkmarx.Preset {
return []checkmarx.Preset{checkmarx.Preset{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, checkmarx.Preset{ID: 10048, Name: "SAP JS Default", OwnerName: "16"}}
return []checkmarx.Preset{{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, {ID: 10048, Name: "SAP JS Default", OwnerName: "16"}}
}
func (sys *systemMock) GetProjects() []checkmarx.Project {
return []checkmarx.Project{checkmarx.Project{ID: 15, Name: "OtherTest", TeamID: "16"}, checkmarx.Project{ID: 1, Name: "Test", TeamID: "16"}}
return []checkmarx.Project{{ID: 15, Name: "OtherTest", TeamID: "16"}, {ID: 1, Name: "Test", TeamID: "16"}}
}
func (sys *systemMock) GetTeams() []checkmarx.Team {
return []checkmarx.Team{checkmarx.Team{ID: "16", FullName: "OpenSource/Cracks/16"}, checkmarx.Team{ID: "15", FullName: "OpenSource/Cracks/15"}}
return []checkmarx.Team{{ID: "16", FullName: "OpenSource/Cracks/16"}, {ID: "15", FullName: "OpenSource/Cracks/15"}}
}
type systemMockForExistingProject struct {
@ -157,7 +157,7 @@ func (sys *systemMockForExistingProject) GetProjectByID(projectID int) (bool, ch
return false, checkmarx.Project{}
}
func (sys *systemMockForExistingProject) GetProjectsByNameAndTeam(projectName, teamID string) []checkmarx.Project {
return []checkmarx.Project{checkmarx.Project{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}}
return []checkmarx.Project{{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}}
}
func (sys *systemMockForExistingProject) FilterTeamByName(teams []checkmarx.Team, teamName string) checkmarx.Team {
return checkmarx.Team{ID: "16", FullName: "OpenSource/Cracks/16"}
@ -178,7 +178,7 @@ func (sys *systemMockForExistingProject) GetResults(scanID int) checkmarx.Result
return checkmarx.ResultsStatistics{}
}
func (sys *systemMockForExistingProject) GetScans(projectID int) (bool, []checkmarx.ScanStatus) {
return true, []checkmarx.ScanStatus{checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: false}}
return true, []checkmarx.ScanStatus{{IsIncremental: true}, {IsIncremental: true}, {IsIncremental: true}, {IsIncremental: false}}
}
func (sys *systemMockForExistingProject) GetScanStatusAndDetail(scanID int) (string, checkmarx.ScanStatusDetail) {
return "Finished", checkmarx.ScanStatusDetail{Stage: "", Step: ""}
@ -206,13 +206,13 @@ func (sys *systemMockForExistingProject) CreateBranch(projectID int, branchName
return 0
}
func (sys *systemMockForExistingProject) GetPresets() []checkmarx.Preset {
return []checkmarx.Preset{checkmarx.Preset{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, checkmarx.Preset{ID: 10048, Name: "SAP JS Default", OwnerName: "16"}}
return []checkmarx.Preset{{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, {ID: 10048, Name: "SAP JS Default", OwnerName: "16"}}
}
func (sys *systemMockForExistingProject) GetProjects() []checkmarx.Project {
return []checkmarx.Project{checkmarx.Project{ID: 1, Name: "TestExisting", TeamID: "16"}}
return []checkmarx.Project{{ID: 1, Name: "TestExisting", TeamID: "16"}}
}
func (sys *systemMockForExistingProject) GetTeams() []checkmarx.Team {
return []checkmarx.Team{checkmarx.Team{ID: "16", FullName: "OpenSource/Cracks/16"}, checkmarx.Team{ID: "15", FullName: "OpenSource/Cracks/15"}}
return []checkmarx.Team{{ID: "16", FullName: "OpenSource/Cracks/16"}, {ID: "15", FullName: "OpenSource/Cracks/15"}}
}
func TestFilterFileGlob(t *testing.T) {

View File

@ -37,9 +37,9 @@ func TestCloudFoundryCreateService(t *testing.T) {
}
error := runCloudFoundryCreateService(&config, &telemetryData, cf)
if assert.NoError(t, error) {
assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
m.Calls)
}
})
@ -59,9 +59,9 @@ func TestCloudFoundryCreateService(t *testing.T) {
}
error := runCloudFoundryCreateService(&config, &telemetryData, cf)
if assert.NoError(t, error) {
assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-t", "testTag, testTag2"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-t", "testTag, testTag2"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
m.Calls)
}
})
@ -80,9 +80,9 @@ func TestCloudFoundryCreateService(t *testing.T) {
}
error := runCloudFoundryCreateService(&config, &telemetryData, cf)
if assert.NoError(t, error) {
assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-b", "testBroker"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-b", "testBroker"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
m.Calls)
}
})
@ -101,9 +101,9 @@ func TestCloudFoundryCreateService(t *testing.T) {
}
error := runCloudFoundryCreateService(&config, &telemetryData, cf)
if assert.NoError(t, error) {
assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-c", "testConfig.json"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-c", "testConfig.json"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
m.Calls)
}
})
@ -161,9 +161,9 @@ func TestCloudFoundryCreateService(t *testing.T) {
}
error := runCloudFoundryCreateService(&config, &telemetryData, cf)
if assert.NoError(t, error) {
assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--var", "name1=Test1", "--var", "name2=Test2"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--var", "name1=Test1", "--var", "name2=Test2"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
m.Calls)
}
})
@ -218,9 +218,9 @@ func TestCloudFoundryCreateService(t *testing.T) {
}
error := runCloudFoundryCreateService(&config, &telemetryData, cf)
if assert.NoError(t, error) {
assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--vars-file", "varsTest.yml", "--vars-file", "varsTest2.yml"}},
mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--vars-file", "varsTest.yml", "--vars-file", "varsTest2.yml"}},
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}},
m.Calls)
}
})

View File

@ -263,8 +263,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{"push", "-f", "manifest.yml"}},
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{"push", "-f", "manifest.yml"}},
}, s.Calls)
})
})
@ -341,8 +341,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{"push",
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{"push",
"testAppName",
"--docker-image",
"repo/image:tag",
@ -380,8 +380,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{"push",
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{"push",
"testAppName",
"--docker-image",
"repo/image:tag",
@ -427,8 +427,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"blue-green-deploy",
"testAppName",
"--delete-old-apps",
@ -469,8 +469,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"push",
"-f",
"test-manifest.yml",
@ -528,14 +528,14 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"blue-green-deploy",
"myTestApp",
"-f",
"test-manifest.yml",
}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{
"stop",
"myTestApp-old",
// MIGRATE FFROM GROOVY: in contrast to groovy there is not redirect of everything &> to a file since we
@ -589,7 +589,7 @@ func TestCfDeployment(t *testing.T) {
return manifestMock{
manifestFileName: "test-manifest.yml",
apps: []map[string]interface{}{
map[string]interface{}{
{
"name": "app1",
"no-route": true,
},
@ -609,8 +609,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"push",
"myTestApp",
"-f",
@ -711,8 +711,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"push",
"myTestApp",
"-f",
@ -748,7 +748,7 @@ func TestCfDeployment(t *testing.T) {
return manifestMock{
manifestFileName: "test-manifest.yml",
apps: []map[string]interface{}{
map[string]interface{}{
{
"there-is": "no-app-name",
},
},
@ -795,8 +795,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"bg-deploy",
"target/test.mtar",
"-f",
@ -836,7 +836,7 @@ func TestCfDeployment(t *testing.T) {
return manifestMock{
manifestFileName: "test-manifest.yml",
apps: []map[string]interface{}{
map[string]interface{}{
{
"name": "myApp",
},
},
@ -857,8 +857,8 @@ func TestCfDeployment(t *testing.T) {
// Revisit: we don't verify a log message in case of a non existing vars file
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"push",
"testAppName",
"--var",
@ -896,7 +896,7 @@ func TestCfDeployment(t *testing.T) {
return manifestMock{
manifestFileName: "test-manifest.yml",
apps: []map[string]interface{}{
map[string]interface{}{
{
"name": "myApp",
},
},
@ -916,8 +916,8 @@ func TestCfDeployment(t *testing.T) {
// Revisit: we don't verify a log message in case of a non existing vars file
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{
"push",
"testAppName",
"--vars-file",
@ -966,8 +966,8 @@ func TestCfDeployment(t *testing.T) {
withLoginAndLogout(t, func(t *testing.T) {
assert.Equal(t, s.Calls, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{"plugins"}},
mock.ExecCall{Exec: "cf", Params: []string{"deploy", "xyz.mtar", "-f"}}})
{Exec: "cf", Params: []string{"plugins"}},
{Exec: "cf", Params: []string{"deploy", "xyz.mtar", "-f"}}})
})
}

View File

@ -21,7 +21,7 @@ func TestDiscoverySuccess(t *testing.T) {
httpClient := httpMockGcts{
StatusCode: 200,
Header: map[string][]string{"x-csrf-token": []string{"ZegUEgfa50R7ZfGGxOtx2A=="}},
Header: map[string][]string{"x-csrf-token": {"ZegUEgfa50R7ZfGGxOtx2A=="}},
ResponseBody: `
<?xml version="1.0" encoding="utf-8"?>
<app:service xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"/>

View File

@ -19,7 +19,7 @@ func kanikoExecute(config kanikoExecuteOptions, telemetryData *telemetry.CustomD
// for command execution use Command
c := command.Command{
ErrorCategoryMapping: map[string][]string{
log.ErrorConfiguration.String(): []string{
log.ErrorConfiguration.String(): {
"unsupported status code 401",
},
},

View File

@ -51,13 +51,13 @@ cd /test
tempDir: "/test",
},
Networks: []string{networkName},
NetworkAliases: map[string][]string{networkName: []string{"karma"}},
NetworkAliases: map[string][]string{networkName: {"karma"}},
}
reqSel := testcontainers.ContainerRequest{
Image: "selenium/standalone-chrome",
Networks: []string{networkName},
NetworkAliases: map[string][]string{networkName: []string{"selenium"}},
NetworkAliases: map[string][]string{networkName: {"selenium"}},
}
provider, err := testcontainers.ProviderDocker.GetProvider()

View File

@ -79,7 +79,7 @@ func TestCloudFoundryLogin(t *testing.T) {
if assert.EqualError(t, err, "Failed to login to Cloud Foundry: wrong password or account does not exist") {
assert.False(t, cf.loggedIn)
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{
"login",
"-a", "https://api.endpoint.com",
"-o", "testOrg",
@ -109,7 +109,7 @@ func TestCloudFoundryLogin(t *testing.T) {
if assert.NoError(t, err) {
assert.True(t, cf.loggedIn)
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{
"login",
"-a", "https://api.endpoint.com",
"-o", "testOrg",
@ -142,7 +142,7 @@ func TestCloudFoundryLogin(t *testing.T) {
if assert.NoError(t, err) {
assert.True(t, cf.loggedIn)
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{
"login",
"-a", "https://api.endpoint.com",
"-o", "testOrg",
@ -205,7 +205,7 @@ func TestCloudFoundryReadServiceKeyAbapEnvironment(t *testing.T) {
//then
if assert.NoError(t, err) {
assert.Equal(t, []mock.ExecCall{
mock.ExecCall{Exec: "cf", Params: []string{
{Exec: "cf", Params: []string{
"login",
"-a", "https://api.endpoint.com",
"-o", "testOrg",
@ -213,8 +213,8 @@ func TestCloudFoundryReadServiceKeyAbapEnvironment(t *testing.T) {
"-u", "testUser",
"-p", "testPassword",
}},
mock.ExecCall{Exec: "cf", Params: []string{"service-key", "testInstance", "testServiceKeyName"}},
mock.ExecCall{Exec: "cf", Params: []string{"logout"}},
{Exec: "cf", Params: []string{"service-key", "testInstance", "testServiceKeyName"}},
{Exec: "cf", Params: []string{"logout"}},
}, m.Calls)
}
assert.Equal(t, ` {"sap.cloud.service":"com.sap.cloud.abap","url": "`+testURL+`" ,"systemid":"H01","abap":{"username":"`+username+`","password":"`+password+`","communication_scenario_id": "SAP_COM_0510","communication_arrangement_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_system_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_inbound_user_id": "CC0000000001","communication_inbound_user_auth_mode": "2"},"binding":{"env": "cf","version": "0.0.1.1","type": "basic","id": "i6cBiRfZppJdKynaTqa32W"},"preserve_host_header": true}`, abapServiceKey)

View File

@ -249,7 +249,7 @@ steps:
t.Run("Consider defaults from step config", func(t *testing.T) {
var c Config
stepParams := []StepParameters{StepParameters{Name: "p0", Scope: []string{"GENERAL"}, Type: "string", Default: "p0_step_default", Aliases: []Alias{{Name: "p0_alias"}}}}
stepParams := []StepParameters{{Name: "p0", Scope: []string{"GENERAL"}, Type: "string", Default: "p0_step_default", Aliases: []Alias{{Name: "p0_alias"}}}}
testConf := "general:\n p1: p1_conf"
stepConfig, err := c.GetStepConfig(nil, "", ioutil.NopCloser(strings.NewReader(testConf)), nil, false, StepFilters{General: []string{"p0", "p1"}}, stepParams, nil, nil, "stage1", "step1", []Alias{})
@ -263,8 +263,8 @@ steps:
var c Config
stepParams := []StepParameters{
StepParameters{Name: "p0", Scope: []string{"GENERAL"}, Type: "bool", Aliases: []Alias{}},
StepParameters{Name: "p1", Scope: []string{"GENERAL"}, Type: "string", Aliases: []Alias{{Name: "p0/subParam"}}}}
{Name: "p0", Scope: []string{"GENERAL"}, Type: "bool", Aliases: []Alias{}},
{Name: "p1", Scope: []string{"GENERAL"}, Type: "string", Aliases: []Alias{{Name: "p0/subParam"}}}}
testConf := "general:\n p0: true"
stepConfig, err := c.GetStepConfig(nil, "", ioutil.NopCloser(strings.NewReader(testConf)), nil, false, StepFilters{General: []string{"p0", "p1"}}, stepParams, nil, nil, "stage1", "step1", []Alias{{}})
@ -278,7 +278,7 @@ steps:
var c Config
secrets := []StepSecrets{
StepSecrets{Name: "p0", Type: "string", Aliases: []Alias{{Name: "p1/subParam"}}}}
{Name: "p0", Type: "string", Aliases: []Alias{{Name: "p1/subParam"}}}}
testConf := ""
paramJSON := "{\"p1\":{\"subParam\":\"p1_value\"}}"
@ -415,18 +415,18 @@ func TestApplyAliasConfig(t *testing.T) {
},
},
Stages: map[string]map[string]interface{}{
"stage1": map[string]interface{}{
"stage1": {
"p3_notused": "p3_stage",
"p4_alias": "p4_stage",
},
},
Steps: map[string]map[string]interface{}{
"step1": map[string]interface{}{
"step1": {
"p5_notused": "p5_step",
"p6_alias": "p6_step",
"p7": "p7_step",
},
"stepAlias1": map[string]interface{}{
"stepAlias1": {
"p7": "p7_stepAlias",
"p8_alias": "p8_stepAlias",
"p9": "p9_stepAlias",
@ -491,15 +491,15 @@ func TestCopyStepAliasConfig(t *testing.T) {
t.Run("Step config available", func(t *testing.T) {
c := Config{
Steps: map[string]map[string]interface{}{
"step1": map[string]interface{}{
"step1": {
"p1": "p1_step",
"p2": "p2_step",
},
"stepAlias1": map[string]interface{}{
"stepAlias1": {
"p2": "p2_stepAlias",
"p3": "p3_stepAlias",
},
"stepAlias2": map[string]interface{}{
"stepAlias2": {
"p3": "p3_stepAlias2",
"p4": "p4_stepAlias2",
},
@ -508,17 +508,17 @@ func TestCopyStepAliasConfig(t *testing.T) {
expected := Config{
Steps: map[string]map[string]interface{}{
"step1": map[string]interface{}{
"step1": {
"p1": "p1_step",
"p2": "p2_step",
"p3": "p3_stepAlias",
"p4": "p4_stepAlias2",
},
"stepAlias1": map[string]interface{}{
"stepAlias1": {
"p2": "p2_stepAlias",
"p3": "p3_stepAlias",
},
"stepAlias2": map[string]interface{}{
"stepAlias2": {
"p3": "p3_stepAlias2",
"p4": "p4_stepAlias2",
},
@ -532,7 +532,7 @@ func TestCopyStepAliasConfig(t *testing.T) {
t.Run("Step config not available", func(t *testing.T) {
c := Config{
Steps: map[string]map[string]interface{}{
"stepAlias1": map[string]interface{}{
"stepAlias1": {
"p2": "p2_stepAlias",
},
},
@ -540,10 +540,10 @@ func TestCopyStepAliasConfig(t *testing.T) {
expected := Config{
Steps: map[string]map[string]interface{}{
"step1": map[string]interface{}{
"step1": {
"p2": "p2_stepAlias",
},
"stepAlias1": map[string]interface{}{
"stepAlias1": {
"p2": "p2_stepAlias",
},
},

View File

@ -262,7 +262,7 @@ func TestGetContextParameterFilters(t *testing.T) {
Spec: StepSpec{
Inputs: StepInputs{
Parameters: []StepParameters{
StepParameters{ResourceRef: []ResourceReference{ResourceReference{Type: "vaultSecret"}}},
{ResourceRef: []ResourceReference{{Type: "vaultSecret"}}},
},
},
},

View File

@ -97,7 +97,7 @@ func stepParam(name string, refType string, refPaths ...string) StepParameters {
return StepParameters{
Name: name,
ResourceRef: []ResourceReference{
ResourceReference{
{
Type: refType,
Paths: refPaths,
},

View File

@ -48,7 +48,7 @@ func TestSendRequest(t *testing.T) {
expected string
}{
{client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, method: "GET", expected: "OK"},
{client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, method: "GET", header: map[string][]string{"Testheader": []string{"Test1", "Test2"}}, expected: "OK"},
{client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, method: "GET", header: map[string][]string{"Testheader": {"Test1", "Test2"}}, expected: "OK"},
{client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, cookies: []*http.Cookie{{Name: "TestCookie1", Value: "TestValue1"}, {Name: "TestCookie2", Value: "TestValue2"}}, method: "GET", expected: "OK"},
{client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http"), username: "TestUser", password: "TestPwd"}, method: "GET", expected: "OK"},
}
@ -166,7 +166,7 @@ func TestUploadRequest(t *testing.T) {
}{
{clientOptions: ClientOptions{}, method: "PUT", expected: "OK"},
{clientOptions: ClientOptions{}, method: "POST", expected: "OK"},
{clientOptions: ClientOptions{}, method: "POST", header: map[string][]string{"Testheader": []string{"Test1", "Test2"}}, expected: "OK"},
{clientOptions: ClientOptions{}, method: "POST", header: map[string][]string{"Testheader": {"Test1", "Test2"}}, expected: "OK"},
{clientOptions: ClientOptions{}, cookies: []*http.Cookie{{Name: "TestCookie1", Value: "TestValue1"}, {Name: "TestCookie2", Value: "TestValue2"}}, method: "POST", expected: "OK"},
{clientOptions: ClientOptions{Username: "TestUser", Password: "TestPwd"}, method: "POST", expected: "OK"},
}

View File

@ -18,8 +18,8 @@ func TestPersistReportAndLinks(t *testing.T) {
// clean up tmp dir
defer os.RemoveAll(workspace)
reports := []Path{Path{Target: "testFile1.json", Mandatory: true}, Path{Target: "testFile2.json"}}
links := []Path{Path{Target: "https://1234568.com/test", Name: "Weblink"}}
reports := []Path{{Target: "testFile1.json", Mandatory: true}, {Target: "testFile2.json"}}
links := []Path{{Target: "https://1234568.com/test", Name: "Weblink"}}
PersistReportsAndLinks("checkmarxExecuteScan", workspace, reports, links)
reportsJSONPath := filepath.Join(workspace, "checkmarxExecuteScan_reports.json")

View File

@ -312,7 +312,7 @@ func (pc *Protecode) UploadScanFile(cleanupMode, group, filePath, fileName strin
// DeclareFetchURL configures the fetch url for the protecode scan
func (pc *Protecode) DeclareFetchURL(cleanupMode, group, fetchURL string) *ResultData {
deleteBinary := (cleanupMode == "binary" || cleanupMode == "complete")
headers := map[string][]string{"Group": {group}, "Delete-Binary": {fmt.Sprintf("%v", deleteBinary)}, "Url": {fetchURL}, "Content-Type": []string{"application/json"}}
headers := map[string][]string{"Group": {group}, "Delete-Binary": {fmt.Sprintf("%v", deleteBinary)}, "Url": {fetchURL}, "Content-Type": {"application/json"}}
protecodeURL := fmt.Sprintf("%v/api/fetch/", pc.serverURL)
r, err := pc.sendAPIRequest(http.MethodPost, protecodeURL, headers)

View File

@ -1,3 +1 @@
package versioning
import ()

View File

@ -76,7 +76,7 @@ func TestFilesRelated(t *testing.T) {
setupFileMock(map[string][]byte{
"manifest.yml": []byte("a: dummy"),
"replacements.yml": []byte{},
"replacements.yml": {},
})
updated, err := Substitute("manifest.yml", map[string]interface{}{}, []string{"replacements.yml"})
@ -95,7 +95,7 @@ func TestFilesRelated(t *testing.T) {
setupFileMock(map[string][]byte{
"manifest.yml": []byte("a: dummy"),
"replacements.yml": []byte{},
"replacements.yml": {},
})
_traverse = func(interface{}, map[string]interface{}) (interface{}, bool, error) {