1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00
sap-jenkins-library/cmd/abapAddonAssemblyKitCheck_test.go
2024-06-20 10:44:12 +02:00

61 lines
1.6 KiB
Go

//go:build unit
// +build unit
package cmd
import (
"testing"
"github.com/SAP/jenkins-library/pkg/abap/aakaas"
"github.com/SAP/jenkins-library/pkg/abaputils"
"github.com/stretchr/testify/assert"
)
func TestRunAbapAddonAssemblyKitCheck(t *testing.T) {
var config abapAddonAssemblyKitCheckOptions
var cpe abapAddonAssemblyKitCheckCommonPipelineEnvironment
bundle := aakaas.NewAakBundleMock()
utils := bundle.GetUtils()
config.Username = "dummyUser"
config.Password = "dummyPassword"
t.Run("happy path", func(t *testing.T) {
config.AddonDescriptorFileName = "addon.yml.mock"
bundle.SetBody(aakaas.ResponseCheck)
bundle.MockAddonDescriptor = abaputils.AddonDescriptor{
AddonProduct: "/DRNMSPC/PRD01",
AddonVersionYAML: "2.0.0",
Repositories: []abaputils.Repository{
{
Name: "/DRNMSPC/COMP01",
VersionYAML: "2.0.0",
},
{
Name: "/DRNMSPC/COMP02",
VersionYAML: "1.0.0",
},
},
}
err := runAbapAddonAssemblyKitCheck(&config, utils, &cpe)
assert.NoError(t, err)
})
t.Run("error path", func(t *testing.T) {
config.AddonDescriptorFileName = "addon.yml.mock"
bundle.SetBody(aakaas.ResponseCheck)
bundle.MockAddonDescriptor = abaputils.AddonDescriptor{
AddonProduct: "/DRNMSPC/PRD01",
AddonVersionYAML: "2.0.0",
Repositories: []abaputils.Repository{
//no repos should fail during pvh creation...
},
}
err := runAbapAddonAssemblyKitCheck(&config, utils, &cpe)
assert.EqualError(t, err, "addonDescriptor must contain at least one software component repository")
})
}