mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
e6c5c8a72f
* Update abapAddonAssemblyKitReleasePackages.go * add error handling for initAAKaaS * runtime to config, url.QueryEscape, check return body * Update abapAddonAssemblyKitCheckCVs_test.go * add log entrys for testing * correct yaml * change unmarshal logic * Update abapAddonAssemblyKitCheckPV_test.go * adding utils functionality * Update bfw_test.go * reset CheckPV * reset CheckCVs * reset ReserveNextPackages * set back CheckPV and CheckCVs * moving mock * renaming * renaming * moving mocking to checkCVs test * fixing unittests * trying mock with comment * referencing unittest to mockfile * Update abapAddonAssemblyKitCheckCVs.go * Update cmd/abapAddonAssemblyKitCheckPV.go Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com> * Update cmd/abapAddonAssemblyKitReleasePackages.go Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com> * Update cmd/abapAddonAssemblyKitPublishTargetVector.go Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com> * Update cmd/abapAddonAssemblyKitReserveNextPackages.go Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com> * fixing unittests * fixing mock comment Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>
85 lines
2.3 KiB
Go
85 lines
2.3 KiB
Go
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/abap/aakaas"
|
|
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build"
|
|
"github.com/SAP/jenkins-library/pkg/abaputils"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPublishTargetVectorStep(t *testing.T) {
|
|
//setup
|
|
config := abapAddonAssemblyKitPublishTargetVectorOptions{
|
|
TargetVectorScope: "P",
|
|
Username: "dummy",
|
|
Password: "dummy",
|
|
}
|
|
addonDescriptor := abaputils.AddonDescriptor{
|
|
TargetVectorID: "W7Q00207512600000353",
|
|
}
|
|
adoDesc, _ := json.Marshal(addonDescriptor)
|
|
config.AddonDescriptor = string(adoDesc)
|
|
|
|
t.Run("step success prod", func(t *testing.T) {
|
|
//arrange
|
|
mc := abapbuild.NewMockClient()
|
|
mc.AddData(aakaas.AAKaaSHead)
|
|
mc.AddData(aakaas.AAKaaSTVPublishProdPost)
|
|
mc.AddData(aakaas.AAKaaSGetTVPublishRunning)
|
|
mc.AddData(aakaas.AAKaaSGetTVPublishProdSuccess)
|
|
bundle := aakaas.NewAakBundleMockNewMC(&mc)
|
|
utils := bundle.GetUtils()
|
|
|
|
//act
|
|
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, &utils)
|
|
//assert
|
|
assert.NoError(t, err, "Did not expect error")
|
|
})
|
|
|
|
t.Run("step success test", func(t *testing.T) {
|
|
//arrange
|
|
config.TargetVectorScope = "T"
|
|
mc := abapbuild.NewMockClient()
|
|
mc.AddData(aakaas.AAKaaSHead)
|
|
mc.AddData(aakaas.AAKaaSTVPublishTestPost)
|
|
mc.AddData(aakaas.AAKaaSGetTVPublishRunning)
|
|
mc.AddData(aakaas.AAKaaSGetTVPublishTestSuccess)
|
|
bundle := aakaas.NewAakBundleMockNewMC(&mc)
|
|
utils := bundle.GetUtils()
|
|
|
|
//act
|
|
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, &utils)
|
|
//assert
|
|
assert.NoError(t, err, "Did not expect error")
|
|
})
|
|
|
|
t.Run("step fail http", func(t *testing.T) {
|
|
//arrange
|
|
bundle := aakaas.NewAakBundleMock()
|
|
bundle.SetBody("dummy")
|
|
bundle.SetError("dummy")
|
|
utils := bundle.GetUtils()
|
|
|
|
//act
|
|
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, &utils)
|
|
//assert
|
|
assert.Error(t, err, "Must end with error")
|
|
})
|
|
|
|
t.Run("step fail no id", func(t *testing.T) {
|
|
//arrange
|
|
config := abapAddonAssemblyKitPublishTargetVectorOptions{}
|
|
mc := abapbuild.NewMockClient()
|
|
bundle := aakaas.NewAakBundleMockNewMC(&mc)
|
|
utils := bundle.GetUtils()
|
|
|
|
//act
|
|
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, &utils)
|
|
//assert
|
|
assert.Error(t, err, "Must end with error")
|
|
})
|
|
}
|