Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kits/bigquery-firestore-export/src/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ export async function constructUpdateTransferConfigRequest(
updatedFields.partitioning_field.stringValue = newPartitioningField;
}

if (config.displayName !== transferConfig.displayName) {
updateMask.push("display_name");
updatedConfig.displayName = config.displayName;
}

if (config.schedule !== transferConfig.schedule) {
updateMask.push("schedule");
updatedConfig.schedule = config.schedule;
Expand Down
58 changes: 58 additions & 0 deletions kits/bigquery-firestore-export/tests/dts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe("constructUpdateTransferConfigRequest", () => {
const client = clientWithTransferConfig({
name: "projects/p/locations/us/transferConfigs/c",
destinationDatasetId: "analytics",
displayName: "Users export",
schedule: "every 24 hours",
notificationPubsubTopic:
"projects/test-project/topics/kit-users-export-processMessages",
Expand All @@ -95,6 +96,63 @@ describe("constructUpdateTransferConfigRequest", () => {
expect(request.updateMask?.paths).toEqual(["params"]);
});

test("updates the display name when it changed", async () => {
const client = clientWithTransferConfig({
name: "projects/p/locations/us/transferConfigs/c",
destinationDatasetId: "analytics",
displayName: "Old export name",
schedule: "every 24 hours",
notificationPubsubTopic:
"projects/test-project/topics/kit-users-export-processMessages",
params: {
fields: {
query: { stringValue: config.queryString },
destination_table_name_template: {
stringValue: 'users_{run_time|"%H%M%S"}',
},
partitioning_field: { stringValue: "created_at" },
},
},
});

const request = await constructUpdateTransferConfigRequest(
client,
"projects/p/locations/us/transferConfigs/c",
config
);

expect(request.updateMask?.paths).toEqual(["display_name"]);
expect(request.transferConfig?.displayName).toBe("Users export");
});

test("leaves the display name out of the mask when unchanged", async () => {
const client = clientWithTransferConfig({
name: "projects/p/locations/us/transferConfigs/c",
destinationDatasetId: "analytics",
displayName: "Users export",
schedule: "every 12 hours",
notificationPubsubTopic:
"projects/test-project/topics/kit-users-export-processMessages",
params: {
fields: {
query: { stringValue: config.queryString },
destination_table_name_template: {
stringValue: 'users_{run_time|"%H%M%S"}',
},
partitioning_field: { stringValue: "created_at" },
},
},
});

const request = await constructUpdateTransferConfigRequest(
client,
"projects/p/locations/us/transferConfigs/c",
config
);

expect(request.updateMask?.paths).toEqual(["schedule"]);
});

test("rejects clearing an existing partitioning field", async () => {
const client = clientWithTransferConfig({
name: "projects/p/locations/us/transferConfigs/c",
Expand Down
Loading