github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/deprovisioning/deregister_cluster_test.go (about) 1 package deprovisioning 2 3 import ( 4 "testing" 5 6 reconcilerApi "github.com/kyma-incubator/reconciler/pkg/keb" 7 "github.com/kyma-project/kyma-environment-broker/internal/reconciler" 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 TestDeregisterClusterStep_Run(t *testing.T) { 15 // given 16 cli := reconciler.NewFakeClient() 17 memoryStorage := storage.NewMemoryStorage() 18 step := NewDeregisterClusterStep(memoryStorage.Operations(), cli) 19 op := fixDeprovisioningOperation() 20 op.ClusterConfigurationVersion = 1 21 memoryStorage.Operations().InsertDeprovisioningOperation(op) 22 op.RuntimeID = "runtime-id" 23 cli.ApplyClusterConfig(reconcilerApi.Cluster{ 24 RuntimeID: op.RuntimeID, 25 }) 26 27 // when 28 _, d, err := step.Run(op.Operation, logrus.New()) 29 30 // then 31 require.NoError(t, err) 32 assert.Zero(t, d) 33 assert.True(t, cli.IsBeingDeleted(op.RuntimeID)) 34 } 35 36 func TestDeregisterClusterStep_RunForNotExistingCluster(t *testing.T) { 37 // given 38 cli := reconciler.NewFakeClient() 39 memoryStorage := storage.NewMemoryStorage() 40 step := NewDeregisterClusterStep(memoryStorage.Operations(), cli) 41 op := fixDeprovisioningOperation() 42 op.ClusterConfigurationVersion = 1 43 op.ClusterConfigurationDeleted = true 44 memoryStorage.Operations().InsertDeprovisioningOperation(op) 45 op.RuntimeID = "runtime-id" 46 47 // when 48 _, d, err := step.Run(op.Operation, logrus.New()) 49 50 // then 51 require.NoError(t, err) 52 assert.Zero(t, d) 53 assert.False(t, cli.IsBeingDeleted(op.RuntimeID)) 54 }