mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +02:00
Abap environment build tag support (#4479)
* Hand over Tag to bf --------- Co-authored-by: rosemarieB <45030247+rosemarieB@users.noreply.github.com>
This commit is contained in:
parent
e117067a66
commit
f9f1b59894
@ -15,15 +15,47 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestReserveNextPackagesStep(t *testing.T) {
|
||||
func arrangeConfig(addonDescriptor abaputils.AddonDescriptor) abapAddonAssemblyKitReserveNextPackagesOptions {
|
||||
var config abapAddonAssemblyKitReserveNextPackagesOptions
|
||||
config.Username = "dummy"
|
||||
config.Password = "dummy"
|
||||
adoDesc, _ := json.Marshal(addonDescriptor)
|
||||
config.AddonDescriptor = string(adoDesc)
|
||||
return config
|
||||
}
|
||||
|
||||
func TestReserveNextPackagesStep(t *testing.T) {
|
||||
var cpe abapAddonAssemblyKitReserveNextPackagesCommonPipelineEnvironment
|
||||
bundle := aakaas.NewAakBundleMock()
|
||||
utils := bundle.GetUtils()
|
||||
t.Run("step success tag", func(t *testing.T) {
|
||||
config := arrangeConfig(abaputils.AddonDescriptor{
|
||||
Repositories: []abaputils.Repository{
|
||||
{
|
||||
Name: "/DRNMSPC/COMP01",
|
||||
VersionYAML: "1.0.0.",
|
||||
Tag: "myTestTagv1.0",
|
||||
},
|
||||
{
|
||||
Name: "/DRNMSPC/COMP02",
|
||||
VersionYAML: "1.0.0.",
|
||||
Tag: "myTestTagv1.0",
|
||||
},
|
||||
},
|
||||
})
|
||||
bodyList := []string{responseReserveNextPackageReleased, responseReserveNextPackagePlanned, responseReserveNextPackagePostReleased, "myToken", responseReserveNextPackagePostPlanned, "myToken"}
|
||||
bundle.SetBodyList(bodyList)
|
||||
err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe)
|
||||
assert.NoError(t, err, "Did not expect error")
|
||||
var addonDescriptorFinal abaputils.AddonDescriptor
|
||||
err = json.Unmarshal([]byte(cpe.abap.addonDescriptor), &addonDescriptorFinal)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "P", addonDescriptorFinal.Repositories[0].Status)
|
||||
assert.Equal(t, "R", addonDescriptorFinal.Repositories[1].Status)
|
||||
})
|
||||
|
||||
t.Run("step success", func(t *testing.T) {
|
||||
addonDescriptor := abaputils.AddonDescriptor{
|
||||
config := arrangeConfig(abaputils.AddonDescriptor{
|
||||
Repositories: []abaputils.Repository{
|
||||
{
|
||||
Name: "/DRNMSPC/COMP01",
|
||||
@ -36,9 +68,7 @@ func TestReserveNextPackagesStep(t *testing.T) {
|
||||
CommitID: "something40charslongxxxxxxxxxxxxxxxxxxxx",
|
||||
},
|
||||
},
|
||||
}
|
||||
adoDesc, _ := json.Marshal(addonDescriptor)
|
||||
config.AddonDescriptor = string(adoDesc)
|
||||
})
|
||||
bodyList := []string{responseReserveNextPackageReleased, responseReserveNextPackagePlanned, responseReserveNextPackagePostReleased, "myToken", responseReserveNextPackagePostPlanned, "myToken"}
|
||||
bundle.SetBodyList(bodyList)
|
||||
err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe)
|
||||
@ -50,29 +80,25 @@ func TestReserveNextPackagesStep(t *testing.T) {
|
||||
assert.Equal(t, "R", addonDescriptorFinal.Repositories[1].Status)
|
||||
})
|
||||
t.Run("step error - invalid input", func(t *testing.T) {
|
||||
addonDescriptor := abaputils.AddonDescriptor{
|
||||
config := arrangeConfig(abaputils.AddonDescriptor{
|
||||
Repositories: []abaputils.Repository{
|
||||
{
|
||||
Name: "/DRNMSPC/COMP01",
|
||||
},
|
||||
},
|
||||
}
|
||||
adoDesc, _ := json.Marshal(addonDescriptor)
|
||||
config.AddonDescriptor = string(adoDesc)
|
||||
})
|
||||
err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe)
|
||||
assert.Error(t, err, "Did expect error")
|
||||
})
|
||||
t.Run("step error - timeout", func(t *testing.T) {
|
||||
addonDescriptor := abaputils.AddonDescriptor{
|
||||
config := arrangeConfig(abaputils.AddonDescriptor{
|
||||
Repositories: []abaputils.Repository{
|
||||
{
|
||||
Name: "/DRNMSPC/COMP01",
|
||||
VersionYAML: "1.0.0.",
|
||||
},
|
||||
},
|
||||
}
|
||||
adoDesc, _ := json.Marshal(addonDescriptor)
|
||||
config.AddonDescriptor = string(adoDesc)
|
||||
})
|
||||
bodyList := []string{responseReserveNextPackageCreationTriggered, responseReserveNextPackagePostPlanned, "myToken"}
|
||||
bundle.SetBodyList(bodyList)
|
||||
bundle.SetMaxRuntime(time.Duration(1 * time.Microsecond))
|
||||
|
@ -180,7 +180,7 @@ func (br *buildWithRepository) start() error {
|
||||
Value: br.repo.PredecessorCommitID})
|
||||
}
|
||||
if br.repo.CommitID != "" {
|
||||
// old value to be used until 2302 [can be deleted latest with 2308]
|
||||
// old value to be used until 2302 [can be deleted earliest with 2311]
|
||||
valuesInput.Values = append(valuesInput.Values,
|
||||
abapbuild.Value{ValueID: "ACTUAL_DELIVERY_COMMIT",
|
||||
Value: br.repo.CommitID})
|
||||
@ -189,6 +189,9 @@ func (br *buildWithRepository) start() error {
|
||||
abapbuild.Value{ValueID: "CURRENT_DELIVERY_COMMIT",
|
||||
Value: br.repo.CommitID})
|
||||
}
|
||||
if br.repo.Tag != "" {
|
||||
valuesInput.Values = append(valuesInput.Values, abapbuild.Value{ValueID: "CURRENT_DELIVERY_TAG", Value: br.repo.Tag})
|
||||
}
|
||||
if len(br.repo.Languages) > 0 {
|
||||
valuesInput.Values = append(valuesInput.Values,
|
||||
abapbuild.Value{ValueID: "SSDC_EXPORT_LANGUAGE_VECTOR",
|
||||
|
Loading…
x
Reference in New Issue
Block a user