Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hariso committed Nov 1, 2024
1 parent 40fde5b commit 88c875d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/connector/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ func TestService_UpdateSuccess(t *testing.T) {
is.NoErr(err)

beforeUpdate := time.Now()
got, err := service.Update(ctx, conn.ID, want)
got, err := service.Update(ctx, conn.ID, "test-plugin", want)
is.NoErr(err)

is.Equal(got.Config, want)
Expand All @@ -545,7 +545,7 @@ func TestService_UpdateInstanceNotFound(t *testing.T) {

service := NewService(logger, db, nil)
// update connector that does not exist
got, err := service.Update(ctx, uuid.NewString(), Config{})
got, err := service.Update(ctx, uuid.NewString(), "foo-plugin", Config{})
is.True(err != nil)
is.True(cerrors.Is(err, ErrInstanceNotFound))
is.Equal(got, nil)
Expand Down
12 changes: 6 additions & 6 deletions pkg/orchestrator/connectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ func TestConnectorOrchestrator_Update_Success(t *testing.T) {
ValidateSourceConfig(gomock.Any(), conn.Plugin, newConfig.Settings).
Return(nil)
consMock.EXPECT().
Update(gomock.AssignableToTypeOf(ctxType), conn.ID, newConfig).
Update(gomock.AssignableToTypeOf(ctxType), conn.ID, conn.Plugin, newConfig).
Return(want, nil)

orc := NewOrchestrator(db, log.Nop(), plsMock, consMock, procsMock, connPluginMock, procPluginMock, lifecycleMock)
got, err := orc.Connectors.Update(ctx, conn.ID, newConfig)
got, err := orc.Connectors.Update(ctx, conn.ID, conn.Plugin, newConfig)
is.NoErr(err)
is.Equal(got, want)
}
Expand All @@ -507,7 +507,7 @@ func TestConnectorOrchestrator_Update_ConnectorNotExist(t *testing.T) {
Return(nil, wantErr)

orc := NewOrchestrator(db, log.Nop(), plsMock, consMock, procsMock, connPluginMock, procPluginMock, lifecycleMock)
got, err := orc.Connectors.Update(ctx, id, connector.Config{})
got, err := orc.Connectors.Update(ctx, id, "test-plugin", connector.Config{})
is.True(got == nil)
is.True(err != nil)
is.True(cerrors.Is(err, wantErr))
Expand Down Expand Up @@ -537,7 +537,7 @@ func TestConnectorOrchestrator_Update_PipelineRunning(t *testing.T) {
Return(pl, nil)

orc := NewOrchestrator(db, log.Nop(), plsMock, consMock, procsMock, connPluginMock, procPluginMock, lifecycleMock)
got, err := orc.Connectors.Update(ctx, conn.ID, connector.Config{})
got, err := orc.Connectors.Update(ctx, conn.ID, conn.Plugin, connector.Config{})
is.True(got == nil)
is.True(err != nil)
is.Equal(pipeline.ErrPipelineRunning, err)
Expand Down Expand Up @@ -571,11 +571,11 @@ func TestConnectorOrchestrator_Update_Fail(t *testing.T) {
ValidateDestinationConfig(gomock.Any(), conn.Plugin, conn.Config.Settings).
Return(nil)
consMock.EXPECT().
Update(gomock.AssignableToTypeOf(ctxType), conn.ID, connector.Config{}).
Update(gomock.AssignableToTypeOf(ctxType), conn.ID, conn.Plugin, connector.Config{}).
Return(nil, wantErr)

orc := NewOrchestrator(db, log.Nop(), plsMock, consMock, procsMock, connPluginMock, procPluginMock, lifecycleMock)
got, err := orc.Connectors.Update(ctx, conn.ID, connector.Config{})
got, err := orc.Connectors.Update(ctx, conn.ID, conn.Plugin, connector.Config{})
is.True(got == nil)
is.True(err != nil)
is.True(cerrors.Is(err, wantErr))
Expand Down
4 changes: 4 additions & 0 deletions pkg/provisioning/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ func TestActionsBuilder_PrepareConnectorActions_Update(t *testing.T) {
name: "different Name",
oldConfig: config.Connector{ID: "config-id", Name: "old-name"},
newConfig: config.Connector{ID: "config-id", Name: "new-name"},
}, {
name: "different Plugin",
oldConfig: config.Connector{ID: "config-id", Plugin: "old-plugin"},
newConfig: config.Connector{ID: "config-id", Plugin: "new-plugin"},
}, {
name: "different Settings",
oldConfig: config.Connector{ID: "config-id", Settings: map[string]string{"foo": "bar"}},
Expand Down
4 changes: 3 additions & 1 deletion pkg/web/api/connector_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,14 @@ func TestConnectorAPIv1_UpdateConnector(t *testing.T) {
before := newTestSource()
after := newTestSource()
after.ID = before.ID
after.Plugin = "test-plugin"
after.Config = connector.Config{
Name: "A source connector",
Settings: map[string]string{"path": "path/to"},
}
after.State = connector.SourceState{Position: []byte("irrelevant")}

csMock.EXPECT().Update(ctx, before.ID, after.Config).Return(after, nil).Times(1)
csMock.EXPECT().Update(ctx, before.ID, after.Plugin, after.Config).Return(after, nil).Times(1)

now := time.Now()
want := &apiv1.UpdateConnectorResponse{Connector: &apiv1.Connector{
Expand All @@ -432,6 +433,7 @@ func TestConnectorAPIv1_UpdateConnector(t *testing.T) {
&apiv1.UpdateConnectorRequest{
Id: want.Connector.Id,
Config: want.Connector.Config,
Plugin: want.Connector.Plugin,
},
)
is.NoErr(err)
Expand Down

0 comments on commit 88c875d

Please sign in to comment.