mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
3867f37dcf
* api user scatch * cv, pv +steps * dust wipe * escape odata values in filter * use correct validation url * headers * add missing error check * restrict to non revertable packages * Correct dotted-version-string calculation + tests
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/abap/aakaas"
|
|
"github.com/SAP/jenkins-library/pkg/abaputils"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCheckPVStep(t *testing.T) {
|
|
var config abapAddonAssemblyKitCheckPVOptions
|
|
var cpe abapAddonAssemblyKitCheckPVCommonPipelineEnvironment
|
|
bundle := aakaas.NewAakBundleMock()
|
|
bundle.SetBody(aakaas.ResponseCheckPV)
|
|
utils := bundle.GetUtils()
|
|
config.Username = "dummyUser"
|
|
config.Password = "dummyPassword"
|
|
t.Run("step success", func(t *testing.T) {
|
|
config.AddonDescriptorFileName = "success"
|
|
err := runAbapAddonAssemblyKitCheckPV(&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, "0003", addonDescriptorFinal.AddonVersion)
|
|
assert.Equal(t, "0002", addonDescriptorFinal.AddonSpsLevel)
|
|
assert.Equal(t, "0001", addonDescriptorFinal.AddonPatchLevel)
|
|
})
|
|
t.Run("step error - in ReadAddonDescriptor", func(t *testing.T) {
|
|
config.AddonDescriptorFileName = "failing"
|
|
err := runAbapAddonAssemblyKitCheckPV(&config, nil, utils, &cpe)
|
|
assert.Error(t, err, "Did expect error")
|
|
assert.Equal(t, err.Error(), "error in ReadAddonDescriptor")
|
|
})
|
|
t.Run("step error - in validate", func(t *testing.T) {
|
|
config.AddonDescriptorFileName = "success"
|
|
bundle.SetBody("ErrorBody")
|
|
bundle.SetError("error during validation")
|
|
err := runAbapAddonAssemblyKitCheckPV(&config, nil, utils, &cpe)
|
|
assert.Error(t, err, "Did expect error")
|
|
})
|
|
}
|