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