1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/buildsettings/buildSettings_test.go
Anil Keshav a92dd234b1
feat (buildSettingsInfo) new common cpe which holds build settings json value (#3272)
* create build settings for maven

* cases for when mavenBuild may be present

* fixing unit test for mavenBuild to include cpe

* changing position of buildSettngsJson to be called atfter build runs

* package

* extending the struct for other build types

* adding values for mta build settings

* changing config data type

* adding npm build settings

* unit tests

* fix trailing space

* typo correction in yaml

* Vitalii/build settings info (#3277)

* Add buildsettings package

* Improve buildSetting package for mta, npm

* Add unit-test

* Fix

* Fix

Co-authored-by: Vitalii Sidorov <vitalii.sidorov@sap.com>

* review changes

* removing buildTool param

* changing npm script name

* fix npmExecute tests

* including build settings info in npm struct

Co-authored-by: Your Name <you@example.com>
Co-authored-by: kingvvgo <56587879+kingvvgo@users.noreply.github.com>
Co-authored-by: Vitalii Sidorov <vitalii.sidorov@sap.com>
Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
2021-11-16 15:02:57 +01:00

42 lines
1.4 KiB
Go

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{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/\"}]}",
},
}
for _, testCase := range testTableConfig {
builSettings, err := CreateBuildSettingsInfo(&testCase.config, testCase.buildTool)
assert.Nil(t, err)
assert.Equal(t, builSettings, testCase.expected)
}
})
}