github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/provisioning/check_runtime_step_test.go (about) 1 package provisioning 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/kyma-project/control-plane/components/provisioner/pkg/gqlschema" 8 "github.com/kyma-project/kyma-environment-broker/internal" 9 "github.com/kyma-project/kyma-environment-broker/internal/broker" 10 "github.com/kyma-project/kyma-environment-broker/internal/provisioner" 11 "github.com/kyma-project/kyma-environment-broker/internal/ptr" 12 "github.com/kyma-project/kyma-environment-broker/internal/storage" 13 "github.com/pivotal-cf/brokerapi/v8/domain" 14 "github.com/sirupsen/logrus" 15 "github.com/stretchr/testify/assert" 16 ) 17 18 func TestCheckRuntimeStep_RunProvisioningSucceeded(t *testing.T) { 19 for _, tc := range []struct { 20 name string 21 provisionerStatus gqlschema.OperationState 22 expectedRepeat bool 23 }{ 24 { 25 name: "In Progress", 26 provisionerStatus: gqlschema.OperationStateInProgress, 27 expectedRepeat: true, 28 }, 29 { 30 name: "Succeeded", 31 provisionerStatus: gqlschema.OperationStateSucceeded, 32 expectedRepeat: false, 33 }, 34 } { 35 t.Run(tc.name, func(t *testing.T) { 36 // given 37 provisionerClient := provisioner.NewFakeClient() 38 provisionerClient.SetOperation(statusProvisionerOperationID, gqlschema.OperationStatus{ 39 ID: ptr.String(statusProvisionerOperationID), 40 Operation: gqlschema.OperationTypeProvision, 41 State: tc.provisionerStatus, 42 Message: nil, 43 RuntimeID: ptr.String(statusRuntimeID), 44 }) 45 st := storage.NewMemoryStorage() 46 operation := fixOperationRuntimeStatus(broker.GCPPlanID, internal.GCP) 47 operation.RuntimeID = statusRuntimeID 48 operation.DashboardURL = dashboardURL 49 err := st.Operations().InsertOperation(operation) 50 assert.NoError(t, err) 51 52 step := NewCheckRuntimeStep(st.Operations(), provisionerClient, time.Second) 53 54 // when 55 operation, repeat, err := step.Run(operation, logrus.New()) 56 57 // then 58 assert.NoError(t, err) 59 assert.Equal(t, tc.expectedRepeat, repeat > 0) 60 assert.Equal(t, domain.InProgress, operation.State) 61 }) 62 } 63 }