Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
fix: fix update not using name field
Browse files Browse the repository at this point in the history
  • Loading branch information
pinglin committed Sep 1, 2022
1 parent 616ce02 commit f8e98c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions integration-test/rest-destination-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,23 @@ export function CheckUpdate() {
[`PATCH /v1alpha/destination-connectors/${resCSVDst.json().destination_connector.id} response connector configuration`]: (r) => r.json().destination_connector.connector.configuration.destination_path === csvDstConnectorUpdate.connector.configuration.destination_path
});

// Try to update with a non-existing name field (which should be ignored)
csvDstConnectorUpdate = {
"name": `destination-connectors/${randomString(5)}`,
"connector": {
"description": randomString(50),
}
}

resCSVDstUpdate = http.request("PATCH", `${connectorHost}/v1alpha/destination-connectors/${resCSVDst.json().destination_connector.id}`,
JSON.stringify(csvDstConnectorUpdate), {
headers: { "Content-Type": "application/json" },
})

check(resCSVDstUpdate, {
[`PATCH /v1alpha/destination-connectors/${resCSVDst.json().destination_connector.id} with non-existing name field response status 200`]: (r) => r.status === 200,
})

check(http.request("DELETE", `${connectorHost}/v1alpha/destination-connectors/${csvDstConnector.id}`), {
[`DELETE /v1alpha/destination-connectors/${csvDstConnector.id} response status 204`]: (r) => r.status === 204,
});
Expand Down
6 changes: 3 additions & 3 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ func (h *handler) updateConnector(ctx context.Context, req interface{}) (resp in
connID = getResp.GetSourceConnector().GetId()
connType = datamodel.ConnectorType(connectorPB.ConnectorType_CONNECTOR_TYPE_SOURCE)

dbConnDefID, err := resource.GetRscNameID(v.GetSourceConnector().GetSourceConnectorDefinition())
dbConnDefID, err := resource.GetRscNameID(getResp.GetSourceConnector().GetSourceConnectorDefinition())
if err != nil {
return resp, err
}
Expand Down Expand Up @@ -793,7 +793,7 @@ func (h *handler) updateConnector(ctx context.Context, req interface{}) (resp in
getResp, err := h.GetDestinationConnector(
ctx,
&connectorPB.GetDestinationConnectorRequest{
Name: fmt.Sprintf("destination-connectors/%s", v.GetDestinationConnector().GetId()),
Name: v.GetDestinationConnector().GetName(),
View: connectorPB.View_VIEW_FULL.Enum(),
})
if err != nil {
Expand Down Expand Up @@ -845,7 +845,7 @@ func (h *handler) updateConnector(ctx context.Context, req interface{}) (resp in
connID = getResp.GetDestinationConnector().GetId()
connType = datamodel.ConnectorType(connectorPB.ConnectorType_CONNECTOR_TYPE_DESTINATION)

dbConnDefID, err := resource.GetRscNameID(v.GetDestinationConnector().GetDestinationConnectorDefinition())
dbConnDefID, err := resource.GetRscNameID(getResp.GetDestinationConnector().GetDestinationConnectorDefinition())
if err != nil {
return resp, err
}
Expand Down

0 comments on commit f8e98c3

Please sign in to comment.