github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/steps/kyma_template_test.go (about)

     1  package steps
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/kyma-project/kyma-environment-broker/internal"
     7  	"github.com/kyma-project/kyma-environment-broker/internal/fixture"
     8  	"github.com/kyma-project/kyma-environment-broker/internal/storage"
     9  	"github.com/sirupsen/logrus"
    10  	"github.com/stretchr/testify/assert"
    11  	"github.com/stretchr/testify/require"
    12  )
    13  
    14  func TestInitKymaTemplate_Run(t *testing.T) {
    15  	// given
    16  	db := storage.NewMemoryStorage()
    17  	operation := fixture.FixOperation("op-id", "inst-id", internal.OperationTypeProvision)
    18  	db.Operations().InsertOperation(operation)
    19  	svc := NewInitKymaTemplate(db.Operations())
    20  	ic := fixture.FixInputCreator("aws")
    21  	ic.Config = &internal.ConfigForPlan{
    22  		KymaTemplate: `
    23  apiVersion: operator.kyma-project.io/v1beta2
    24  kind: Kyma
    25  metadata:
    26      name: my-kyma
    27      namespace: kyma-system
    28  spec:
    29      sync:
    30          strategy: secret
    31      channel: stable
    32      modules: []
    33  `,
    34  	}
    35  	operation.InputCreator = ic
    36  
    37  	// when
    38  	op, backoff, err := svc.Run(operation, logrus.New())
    39  	require.NoError(t, err)
    40  
    41  	// then
    42  	assert.Zero(t, backoff)
    43  	assert.Equal(t, "kyma-system", op.KymaResourceNamespace)
    44  	assert.Equal(t, ic.Config.KymaTemplate, op.KymaTemplate)
    45  }