1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/cmd/abapEnvironmentAssembleConfirm_test.go
Christian Luttenberger c8e9e44f23
New pipeline step assembly confirm (#2631)
* Add new pipeline step

* new pipeline stage

* Cleanup Test

* Adding new step to pipeline - stage publish

* Move from Publish to Build

* Adjusting documentation for move from publish to build

* Change Release with Confirm Step in Build Stage

* codeclimate

* Code Climate

* Code Climate spaces

Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>
2021-02-23 11:11:52 +01:00

60 lines
1.4 KiB
Go

package cmd
import (
"testing"
"time"
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build"
"github.com/SAP/jenkins-library/pkg/abaputils"
"github.com/stretchr/testify/assert"
)
func TestStartingConfirm(t *testing.T) {
t.Run("Run starting", func(t *testing.T) {
client := &abapbuild.ClMock{
Token: "MyToken",
}
conn := new(abapbuild.Connector)
conn.Client = client
conn.Header = make(map[string][]string)
var repos []abaputils.Repository
repo := abaputils.Repository{
Name: "RepoA",
Version: "0001",
PackageName: "Package",
PackageType: "AOI",
SpLevel: "0000",
PatchLevel: "0000",
Status: "P",
Namespace: "/DEMO/",
}
repos = append(repos, repo)
repo.Status = "R"
repos = append(repos, repo)
builds, err := startingConfirm(repos, *conn, time.Duration(0*time.Second))
assert.NoError(t, err)
assert.Equal(t, 1, len(builds))
assert.Equal(t, abapbuild.Accepted, builds[0].build.RunState)
})
}
func TestStartingConfirmInvalidInput(t *testing.T) {
t.Run("Run starting", func(t *testing.T) {
client := &abapbuild.ClMock{
Token: "MyToken",
}
conn := new(abapbuild.Connector)
conn.Client = client
conn.Header = make(map[string][]string)
var repos []abaputils.Repository
repo := abaputils.Repository{
Name: "RepoA",
Status: "P",
}
repos = append(repos, repo)
_, err := startingConfirm(repos, *conn, time.Duration(0*time.Second))
assert.Error(t, err)
})
}