1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-16 11:09:33 +02:00
sap-jenkins-library/cmd/abapAddonAssemblyKitPublishTargetVector_test.go

66 lines
1.5 KiB
Go
Raw Normal View History

AAKaaS: 3 publish target Vector (#2040) * 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 publishTV * AAKaaS 3 Publish TV #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>
2020-09-18 10:24:46 +02:00
package cmd
import (
"encoding/json"
"testing"
"github.com/SAP/jenkins-library/pkg/abaputils"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
func TestPublishTargetVectorStep(t *testing.T) {
//setup
config := abapAddonAssemblyKitPublishTargetVectorOptions{
TargetVectorScope: "P",
}
addonDescriptor := abaputils.AddonDescriptor{
TargetVectorID: "dummy",
}
adoDesc, _ := json.Marshal(addonDescriptor)
config.AddonDescriptor = string(adoDesc)
client := &abaputils.ClientMock{
Body: "dummy",
Token: "myToken",
StatusCode: 200,
}
t.Run("step success prod", func(t *testing.T) {
//act
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, client)
//assert
assert.NoError(t, err, "Did not expect error")
})
t.Run("step success test", func(t *testing.T) {
//arrange
config.TargetVectorScope = "T"
//act
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, client)
//assert
assert.NoError(t, err, "Did not expect error")
})
t.Run("step fail http", func(t *testing.T) {
//arrange
client := &abaputils.ClientMock{
Body: "dummy",
Error: errors.New("dummy"),
}
//act
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, client)
//assert
assert.Error(t, err, "Must end with error")
})
t.Run("step fail no id", func(t *testing.T) {
//arrange
config := abapAddonAssemblyKitPublishTargetVectorOptions{}
//act
err := runAbapAddonAssemblyKitPublishTargetVector(&config, nil, client)
//assert
assert.Error(t, err, "Must end with error")
})
}