From f9f1b59894f5e2e8f356c2a97941e68ce02ea670 Mon Sep 17 00:00:00 2001 From: tiloKo <70266685+tiloKo@users.noreply.github.com> Date: Thu, 20 Jul 2023 15:57:57 +0200 Subject: [PATCH] Abap environment build tag support (#4479) * Hand over Tag to bf --------- Co-authored-by: rosemarieB <45030247+rosemarieB@users.noreply.github.com> --- ...ddonAssemblyKitReserveNextPackages_test.go | 52 ++++++++++++++----- cmd/abapEnvironmentAssemblePackages.go | 5 +- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/cmd/abapAddonAssemblyKitReserveNextPackages_test.go b/cmd/abapAddonAssemblyKitReserveNextPackages_test.go index 577b808c3..3c9e92b73 100644 --- a/cmd/abapAddonAssemblyKitReserveNextPackages_test.go +++ b/cmd/abapAddonAssemblyKitReserveNextPackages_test.go @@ -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)) diff --git a/cmd/abapEnvironmentAssemblePackages.go b/cmd/abapEnvironmentAssemblePackages.go index 3eeee1666..2a5064f97 100644 --- a/cmd/abapEnvironmentAssemblePackages.go +++ b/cmd/abapEnvironmentAssemblePackages.go @@ -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",