mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
3c87648c00
* adding my steps * messy step * Update abapEnvironmentAssembly.go * clean up * change yaml * corrections * Update cloudFoundryDeploy.go * update * delete simulation step * remove simulate * Update PiperGoUtils.groovy * Update PiperGoUtils.groovy * Update CommonStepsTest.groovy * add docu * Update abapEnvironmentAssembly.md * changes due to PR * Update .gitignore * b * CV list * Update abapEnvironmentAssembly.go * testing with simulation * Update abapEnvironmentAssembly.go * remove simulation * renaming * Update mkdocs.yml * moving service key to yaml and fixing code climate * Update abapEnvironmentAssemblePackages.go * Update abapEnvironmentAssemblePackages.go * Update abapEnvironmentAssemblePackages.go * Update abapEnvironmentAssemblePackages.go * change input * Update abapEnvironmentAssemblePackages.go * change json tag * fixed error handling * documentation * Update abapEnvironmentAssemblePackages.md * Update abapEnvironmentAssemblePackages.md * fixing code climate issues * fixing code climate issues * Update abapEnvironmentAssemblePackages.yaml * fixing code climate issues * Update abapEnvironmentAssemblePackages.yaml * adding unittests * adding unittests and improved logging * yaml -> json * change scope of cfServiceKeyName * correct indentation * Update CommonStepsTest.groovy * maintain correct step order * AAKaaS register package * AAKaaS register package #2 * Update documentation/docs/steps/abapAddonAssemblyKitPublishTargetVector.md Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> * AAKaaS register package #3 * AAKaaS release package * Update abapAddonAssemblyKitReleasePackages.go * AAKaas release package #2 Co-authored-by: rosemarieB <45030247+rosemarieB@users.noreply.github.com> Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
101 lines
3.0 KiB
Go
101 lines
3.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/abaputils"
|
|
"github.com/pkg/errors"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestReleasePackagesStep(t *testing.T) {
|
|
var config abapAddonAssemblyKitReleasePackagesOptions
|
|
var cpe abapAddonAssemblyKitReleasePackagesCommonPipelineEnvironment
|
|
client := &abaputils.ClientMock{
|
|
Body: responseRelease,
|
|
Token: "myToken",
|
|
StatusCode: 200,
|
|
}
|
|
timeout := time.Duration(5 * time.Second)
|
|
pollInterval := time.Duration(1 * time.Second)
|
|
t.Run("step success", func(t *testing.T) {
|
|
addonDescriptor := abaputils.AddonDescriptor{
|
|
Repositories: []abaputils.Repository{
|
|
{
|
|
PackageName: "SAPK-002AAINDRNMSPC",
|
|
Status: "L",
|
|
},
|
|
{
|
|
PackageName: "SAPK-001AAINDRNMSPC",
|
|
Status: "R",
|
|
},
|
|
},
|
|
}
|
|
adoDesc, _ := json.Marshal(addonDescriptor)
|
|
config.AddonDescriptor = string(adoDesc)
|
|
|
|
err := runAbapAddonAssemblyKitReleasePackages(&config, nil, client, &cpe, timeout, pollInterval)
|
|
|
|
assert.NoError(t, err, "Did not expect error")
|
|
var addonDescriptorFinal abaputils.AddonDescriptor
|
|
json.Unmarshal([]byte(cpe.abap.addonDescriptor), &addonDescriptorFinal)
|
|
assert.Equal(t, "R", addonDescriptorFinal.Repositories[0].Status)
|
|
})
|
|
|
|
t.Run("step error - invalid input", func(t *testing.T) {
|
|
addonDescriptor := abaputils.AddonDescriptor{
|
|
Repositories: []abaputils.Repository{
|
|
{
|
|
Status: "L",
|
|
},
|
|
},
|
|
}
|
|
adoDesc, _ := json.Marshal(addonDescriptor)
|
|
config.AddonDescriptor = string(adoDesc)
|
|
|
|
err := runAbapAddonAssemblyKitReleasePackages(&config, nil, client, &cpe, timeout, pollInterval)
|
|
assert.Error(t, err, "Did expect error")
|
|
assert.Equal(t, err.Error(), "Parameter missing. Please provide the name of the package which should be released")
|
|
})
|
|
|
|
t.Run("step error - timeout", func(t *testing.T) {
|
|
client.Error = errors.New("Release not finished")
|
|
addonDescriptor := abaputils.AddonDescriptor{
|
|
Repositories: []abaputils.Repository{
|
|
{
|
|
PackageName: "SAPK-001AAINDRNMSPC",
|
|
Status: "L",
|
|
},
|
|
},
|
|
}
|
|
adoDesc, _ := json.Marshal(addonDescriptor)
|
|
config.AddonDescriptor = string(adoDesc)
|
|
|
|
timeout := time.Duration(2 * time.Second)
|
|
err := runAbapAddonAssemblyKitReleasePackages(&config, nil, client, &cpe, timeout, pollInterval)
|
|
assert.Error(t, err, "Did expect error")
|
|
assert.Equal(t, err.Error(), "Timed out")
|
|
})
|
|
}
|
|
|
|
var responseRelease = `{
|
|
"d": {
|
|
"__metadata": {
|
|
"id": "https://W7Q.DMZWDF.SAP.CORP:443/odata/aas_ocs_package/OcsPackageSet('SAPK-001AAINDRNMSPC')",
|
|
"uri": "https://W7Q.DMZWDF.SAP.CORP:443/odata/aas_ocs_package/OcsPackageSet('SAPK-001AAINDRNMSPC')",
|
|
"type": "SSDA.AAS_ODATA_PACKAGE_SRV.OcsPackage"
|
|
},
|
|
"Name": "SAPK-001AAINDRNMSPC",
|
|
"Type": "AOI",
|
|
"Component": "/DRNMSPC/COMP01",
|
|
"Release": "0001",
|
|
"Level": "0000",
|
|
"Status": "R",
|
|
"Operation": "",
|
|
"Namespace": "/DRNMSPC/",
|
|
"Vendorid": "0000203069"
|
|
}
|
|
}`
|