Skip to content

Commit

Permalink
feat: (polling) add e2e test for new connector config update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
laouji committed Jan 3, 2025
1 parent e10af70 commit a464dbb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/testserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ func ConnectorUninstall(ctx context.Context, srv *Server, ver int, id string, re
return srv.Client().Do(ctx, http.MethodDelete, pathPrefix(ver, path), nil, res)
}

func ConnectorConfigUpdate(ctx context.Context, srv *Server, ver int, id string, reqBody any) error {
path := "connectors/" + id + "/config"
if ver == 2 {
return fmt.Errorf("connector update not supported by version %d", ver)
}
return srv.Client().Do(ctx, http.MethodPatch, pathPrefix(ver, path), reqBody, nil)
}

func ConnectorConfig(ctx context.Context, srv *Server, ver int, id string, res any) error {
path := "connectors/" + id + "/config"
if ver == 2 {
Expand Down
31 changes: 31 additions & 0 deletions test/e2e/api_connectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,37 @@ var _ = Context("Payments API Connectors", func() {
})
})

When("updating a connector config", func() {
var (
id uuid.UUID
ver int
connectorRes struct{ Data string }
connectorID string
)
JustBeforeEach(func() {
id = uuid.New()
ver = 3

connectorConf := newConnectorConfigurationFn()(id)
err := ConnectorInstall(ctx, app.GetValue(), ver, connectorConf, &connectorRes)
Expect(err).To(BeNil())
connectorID = connectorRes.Data
blockTillWorkflowComplete(ctx, connectorID, "run-tasks-")
})

It("should be ok with v3", func() {
config := newConnectorConfigurationFn()(id)
config.PollingPeriod = "2m"
err := ConnectorConfigUpdate(ctx, app.GetValue(), ver, connectorID, &config)
Expect(err).To(BeNil())

getRes := struct{ Data ConnectorConf }{}
err = ConnectorConfig(ctx, app.GetValue(), ver, connectorID, &getRes)
Expect(err).To(BeNil())
Expect(getRes.Data).To(Equal(config))
})
})

When("uninstalling a connector", func() {
var (
id uuid.UUID
Expand Down

0 comments on commit a464dbb

Please sign in to comment.