Skip to content

Commit

Permalink
Abap environment build tag support (SAP#4479)
Browse files Browse the repository at this point in the history
* Hand over Tag to bf

---------

Co-authored-by: rosemarieB <[email protected]>
  • Loading branch information
2 people authored and maxatsap committed Jul 23, 2024
1 parent 794c39f commit bad309d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
52 changes: 39 additions & 13 deletions cmd/abapAddonAssemblyKitReserveNextPackages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand All @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion cmd/abapEnvironmentAssemblePackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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",
Expand Down

0 comments on commit bad309d

Please sign in to comment.