Skip to content

Commit

Permalink
KIM Integration - test for Kyma name corrected (#968)
Browse files Browse the repository at this point in the history
initial change for investigation

assertion added
  • Loading branch information
jaroslaw-pieszka authored Jul 31, 2024
1 parent 285b575 commit 98031e8
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions internal/process/provisioning/create_kyma_name_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestCreateKymaNameStep_HappyPath(t *testing.T) {
log := logrus.New()
memoryStorage := storage.NewMemoryStorage()

preOperation := fixture.FixProvisioningOperation(operationID, instanceID)
err := memoryStorage.Operations().InsertOperation(preOperation)
operation := fixProvisioningOperationWithEmptyResourceName()
err := memoryStorage.Operations().InsertOperation(operation)
assert.NoError(t, err)

err = memoryStorage.Instances().Insert(fixInstance())
Expand All @@ -56,29 +56,34 @@ func TestCreateKymaNameStep_HappyPath(t *testing.T) {

// when
entry := log.WithFields(logrus.Fields{"step": "TEST"})
postOperation, backoff, err := step.Run(preOperation, entry)
postOperation, backoff, err := step.Run(operation, entry)

// then
assert.NoError(t, err)
assert.Zero(t, backoff)
assert.Equal(t, preOperation.RuntimeID, postOperation.RuntimeID)
assert.Equal(t, postOperation.KymaResourceName, preOperation.RuntimeID)
assert.Equal(t, operation.RuntimeID, postOperation.RuntimeID)
assert.Equal(t, postOperation.KymaResourceName, operation.RuntimeID)
assert.Equal(t, postOperation.KymaResourceNamespace, "kyma-system")
_, err = memoryStorage.Instances().GetByID(preOperation.InstanceID)
_, err = memoryStorage.Instances().GetByID(operation.InstanceID)
assert.NoError(t, err)

}

func fixProvisioningOperationWithEmptyResourceName() internal.Operation {
preOperation := fixture.FixProvisioningOperation(operationID, instanceID)
preOperation.KymaResourceName = ""
return preOperation
}

func TestCreateKymaNameStep_NoRuntimeID(t *testing.T) {
// given
log := logrus.New()
memoryStorage := storage.NewMemoryStorage()

preOperation := fixture.FixProvisioningOperation(operationID, instanceID)

preOperation.RuntimeID = ""
operation := fixProvisioningOperationWithEmptyResourceName()
operation.RuntimeID = ""

err := memoryStorage.Operations().InsertOperation(preOperation)
err := memoryStorage.Operations().InsertOperation(operation)
assert.NoError(t, err)

err = memoryStorage.Instances().Insert(fixInstance())
Expand All @@ -88,7 +93,7 @@ func TestCreateKymaNameStep_NoRuntimeID(t *testing.T) {

// when
entry := log.WithFields(logrus.Fields{"step": "TEST"})
_, backoff, err := step.Run(preOperation, entry)
_, backoff, err := step.Run(operation, entry)

// then
assert.ErrorContains(t, err, "RuntimeID not set, cannot create Kyma name")
Expand Down

0 comments on commit 98031e8

Please sign in to comment.