github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/provisioning/secret_cm_overrides_test.go (about) 1 package provisioning 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/kyma-project/kyma-environment-broker/internal" 8 "github.com/kyma-project/kyma-environment-broker/internal/process/provisioning/automock" 9 "github.com/kyma-project/kyma-environment-broker/internal/storage" 10 11 "github.com/sirupsen/logrus" 12 "github.com/stretchr/testify/assert" 13 "github.com/stretchr/testify/mock" 14 ) 15 16 func TestOverridesFromSecretsAndConfigStep_Run_WithVersionComputed(t *testing.T) { 17 t.Run("success run", func(t *testing.T) { 18 // Given 19 planName := "gcp" 20 kymaVersion := "1.15.0" 21 22 memoryStorage := storage.NewMemoryStorage() 23 24 inputCreatorMock := &automock.ProvisionerInputCreator{} 25 defer inputCreatorMock.AssertExpectations(t) 26 27 runtimeOverridesMock := &automock.RuntimeOverridesAppender{} 28 defer runtimeOverridesMock.AssertExpectations(t) 29 runtimeOverridesMock.On("Append", inputCreatorMock, planName, kymaVersion).Return(nil).Once() 30 31 operation := internal.Operation{ 32 ProvisioningParameters: internal.ProvisioningParameters{ 33 PlanID: "ca6e5357-707f-4565-bbbd-b3ab732597c6", 34 Parameters: internal.ProvisioningParametersDTO{KymaVersion: kymaVersion}}, 35 InputCreator: inputCreatorMock, 36 Type: internal.OperationTypeProvision, 37 } 38 39 rcvMock := &automock.RuntimeVersionConfiguratorForProvisioning{} 40 defer rcvMock.AssertExpectations(t) 41 rcvMock.On("ForProvisioning", mock.Anything, mock.Anything).Return(&internal.RuntimeVersionData{Version: kymaVersion}, nil).Once() 42 43 step := NewOverridesFromSecretsAndConfigStep(memoryStorage.Operations(), runtimeOverridesMock, rcvMock) 44 45 // When 46 operation, repeat, err := step.Run(operation, logrus.New()) 47 48 // Then 49 assert.NoError(t, err) 50 assert.Equal(t, time.Duration(0), repeat) 51 }) 52 } 53 54 func TestOverridesFromSecretsAndConfigStep_Run_WithVersionFromOperation(t *testing.T) { 55 t.Run("success run", func(t *testing.T) { 56 // Given 57 planName := "gcp" 58 kymaVersion := "1.15.0" 59 60 memoryStorage := storage.NewMemoryStorage() 61 62 inputCreatorMock := &automock.ProvisionerInputCreator{} 63 defer inputCreatorMock.AssertExpectations(t) 64 65 runtimeOverridesMock := &automock.RuntimeOverridesAppender{} 66 defer runtimeOverridesMock.AssertExpectations(t) 67 runtimeOverridesMock.On("Append", inputCreatorMock, planName, kymaVersion).Return(nil).Once() 68 69 operation := internal.Operation{ 70 ProvisioningParameters: internal.ProvisioningParameters{PlanID: "ca6e5357-707f-4565-bbbd-b3ab732597c6"}, 71 InputCreator: inputCreatorMock, 72 RuntimeVersion: internal.RuntimeVersionData{ 73 Version: kymaVersion, 74 }, 75 Type: internal.OperationTypeProvision, 76 } 77 78 rcvMock := &automock.RuntimeVersionConfiguratorForProvisioning{} 79 defer rcvMock.AssertExpectations(t) 80 81 step := NewOverridesFromSecretsAndConfigStep(memoryStorage.Operations(), runtimeOverridesMock, rcvMock) 82 83 // When 84 operation, repeat, err := step.Run(operation, logrus.New()) 85 86 // Then 87 assert.NoError(t, err) 88 assert.Equal(t, time.Duration(0), repeat) 89 }) 90 }