mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
ffc931aad1
* Added unit tag as argument. Added description to runTests command. Changed code generator to have unit build tag in generated unit test files. * Added unit build tag to all unit test files. * added to new unit test unit build tag * Update verify-go.yml * small fix --------- Co-authored-by: Muhammadali Nazarov <Muhammadali.Nazarov@acronis.com> Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
//go:build unit
|
|
// +build unit
|
|
|
|
package buildsettings
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCreateBuildSettingsInfo(t *testing.T) {
|
|
|
|
t.Run("test build settings cpe with no previous and existing values", func(t *testing.T) {
|
|
testTableConfig := []struct {
|
|
config BuildOptions
|
|
buildTool string
|
|
expected string
|
|
}{
|
|
{
|
|
config: BuildOptions{CreateBOM: true},
|
|
buildTool: "golangBuild",
|
|
expected: "{\"golangBuild\":[{\"createBOM\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{DockerImage: "golang:latest"},
|
|
buildTool: "golangBuild",
|
|
expected: "{\"golangBuild\":[{\"dockerImage\":\"golang:latest\"}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{CreateBOM: true},
|
|
buildTool: "gradleBuild",
|
|
expected: "{\"gradleBuild\":[{\"createBOM\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{Publish: true},
|
|
buildTool: "helmExecute",
|
|
expected: "{\"helmExecute\":[{\"publish\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{Publish: true},
|
|
buildTool: "kanikoExecute",
|
|
expected: "{\"kanikoExecute\":[{\"publish\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{Profiles: []string{"profile1", "profile2"}, CreateBOM: true},
|
|
buildTool: "mavenBuild",
|
|
expected: "{\"mavenBuild\":[{\"profiles\":[\"profile1\",\"profile2\"],\"createBOM\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{Profiles: []string{"profile1", "profile2"}, CreateBOM: true, BuildSettingsInfo: "{\"mavenBuild\":[{\"createBOM\":true}]}"},
|
|
buildTool: "mavenBuild",
|
|
expected: "{\"mavenBuild\":[{\"createBOM\":true},{\"profiles\":[\"profile1\",\"profile2\"],\"createBOM\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{Profiles: []string{"release.build"}, Publish: true, GlobalSettingsFile: "http://nexus.test:8081/nexus/"},
|
|
buildTool: "mtaBuild",
|
|
expected: "{\"mtaBuild\":[{\"profiles\":[\"release.build\"],\"publish\":true,\"globalSettingsFile\":\"http://nexus.test:8081/nexus/\"}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{CreateBOM: true},
|
|
buildTool: "pythonBuild",
|
|
expected: "{\"pythonBuild\":[{\"createBOM\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{CreateBOM: true},
|
|
buildTool: "npmExecuteScripts",
|
|
expected: "{\"npmExecuteScripts\":[{\"createBOM\":true}]}",
|
|
},
|
|
{
|
|
config: BuildOptions{DockerImage: "builder:latest"},
|
|
buildTool: "cnbBuild",
|
|
expected: "{\"cnbBuild\":[{\"dockerImage\":\"builder:latest\"}]}",
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testTableConfig {
|
|
buildSettings, err := CreateBuildSettingsInfo(&testCase.config, testCase.buildTool)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, buildSettings, testCase.expected)
|
|
}
|
|
})
|
|
|
|
}
|