Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hariso committed Nov 1, 2024
1 parent 88c875d commit 36a07dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/provisioning/import_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func TestUpdateConnectorAction(t *testing.T) {
}

connSrv := mock.NewConnectorService(ctrl)
connSrv.EXPECT().Update(ctx, haveCfg.ID, wantCfg).Return(instance, nil)
connSrv.EXPECT().Update(ctx, haveCfg.ID, haveCfg.Plugin, wantCfg).Return(instance, nil)
connSrv.EXPECT().RemoveProcessor(ctx, haveCfg.ID, instance.ProcessorIDs[0])
connSrv.EXPECT().RemoveProcessor(ctx, haveCfg.ID, instance.ProcessorIDs[1])
connSrv.EXPECT().AddProcessor(ctx, haveCfg.ID, haveCfg.Processors[0].ID)
Expand Down
19 changes: 4 additions & 15 deletions pkg/provisioning/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,10 @@ func TestActionBuilder_Build(t *testing.T) {
newConfig: newConfig,
pipelineService: pipSrv,
},
deleteConnectorAction{
cfg: oldConfig.Connectors[1],
pipelineID: oldConfig.ID,
connectorService: connSrv,
connectorPluginService: connPlugSrv,
},
createConnectorAction{
cfg: newConfig.Connectors[1],
pipelineID: newConfig.ID,
connectorService: connSrv,
connectorPluginService: connPlugSrv,
updateConnectorAction{
oldConfig: oldConfig.Connectors[1],
newConfig: newConfig.Connectors[1],
connectorService: connSrv,
},
updateConnectorAction{
oldConfig: oldConfig.Connectors[2],
Expand Down Expand Up @@ -638,10 +631,6 @@ func TestActionsBuilder_PrepareConnectorActions_Recreate(t *testing.T) {
name: "different Type",
oldConfig: config.Connector{ID: "config-id", Type: config.TypeSource},
newConfig: config.Connector{ID: "config-id", Type: config.TypeDestination},
}, {
name: "different Plugin",
oldConfig: config.Connector{ID: "config-id", Plugin: "old-plugin"},
newConfig: config.Connector{ID: "config-id", Plugin: "new-plugin"},
}}

for _, tc := range testCases {
Expand Down
6 changes: 3 additions & 3 deletions pkg/provisioning/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func TestService_Init_Update(t *testing.T) {
// update pipeline
pipelineService.EXPECT().Update(anyCtx, p1.P1.ID, p1.P1.Config).Return(oldPipelineInstance, nil)
pipelineService.EXPECT().UpdateDLQ(anyCtx, p1.P1.ID, p1.P1.DLQ)
connService.EXPECT().Update(anyCtx, p1.P1C1.ID, p1.P1C1.Config).Return(oldConnector1Instance, nil)
connService.EXPECT().Update(anyCtx, p1.P1C1.ID, p1.P1C1.Plugin, p1.P1C1.Config).Return(oldConnector1Instance, nil)
procService.EXPECT().Update(anyCtx, p1.P1C2P1.ID, p1.P1C2P1.Config)
procService.EXPECT().Update(anyCtx, p1.P1P1.ID, p1.P1P1.Config)

Expand Down Expand Up @@ -310,15 +310,15 @@ func TestService_Init_RollbackUpdate(t *testing.T) {
// update pipeline
pipelineService.EXPECT().Update(anyCtx, p1.P1.ID, p1.P1.Config).Return(oldPipelineInstance, nil)
pipelineService.EXPECT().UpdateDLQ(anyCtx, p1.P1.ID, p1.P1.DLQ)
connService.EXPECT().Update(anyCtx, p1.P1C1.ID, p1.P1C1.Config).Return(oldConnector1Instance, nil)
connService.EXPECT().Update(anyCtx, p1.P1C1.ID, p1.P1C1.Plugin, p1.P1C1.Config).Return(oldConnector1Instance, nil)
procService.EXPECT().Update(anyCtx, p1.P1C2P1.ID, p1.P1C2P1.Config)
wantErr := cerrors.New("err")
procService.EXPECT().Update(anyCtx, p1.P1P1.ID, p1.P1P1.Config).Return(nil, wantErr) // fails

// rollback changes
procService.EXPECT().Update(anyCtx, oldPipelineProcessorInstance.ID, oldPipelineProcessorInstance.Config)
procService.EXPECT().Update(anyCtx, oldConnectorProcessorInstance.ID, oldConnectorProcessorInstance.Config)
connService.EXPECT().Update(anyCtx, oldConnector1Instance.ID, oldConnector1Instance.Config).Return(oldConnector1Instance, nil)
connService.EXPECT().Update(anyCtx, oldConnector1Instance.ID, oldConnector1Instance.Plugin, oldConnector1Instance.Config).Return(oldConnector1Instance, nil)
pipelineService.EXPECT().Update(anyCtx, oldPipelineInstance.ID, oldPipelineInstance.Config).Return(oldPipelineInstance, nil)
pipelineService.EXPECT().UpdateDLQ(anyCtx, oldPipelineInstance.ID, oldPipelineInstance.DLQ)

Expand Down

0 comments on commit 36a07dc

Please sign in to comment.