Skip to content

Commit 2a1d14a

Browse files
committed
Merge branch 'node-18' of https://github.com/thiyaguk09/nodejs-storage-fork into node-18
2 parents a4ae1cd + 6ec9438 commit 2a1d14a

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

handwritten/storage/src/bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ class Bucket extends ServiceObject<Bucket, BucketMetadata> {
20242024
const body = Object.assign({topic}, options);
20252025

20262026
if (body.topic.indexOf('projects') !== 0) {
2027-
body.topic = 'projects/{{projectId}}/topics/' + body.topic;
2027+
body.topic = `projects/${this.storage.projectId}/topics/` + body.topic;
20282028
}
20292029

20302030
body.topic = `//pubsub.${this.storage.universeDomain}/` + body.topic;

handwritten/storage/src/nodejs-common/service-object.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,17 @@ class ServiceObject<T, K extends BaseMetadata> extends EventEmitter {
506506
responseType: 'json',
507507
url,
508508
...methodConfig.reqOpts,
509-
body: {
509+
body: JSON.stringify({
510510
...methodConfig.reqOpts?.body,
511511
...metadata,
512-
},
512+
}),
513513
queryParameters: {
514514
...methodConfig.reqOpts?.queryParameters,
515515
...options,
516516
},
517+
headers: {
518+
'Content-Type': 'application/json',
519+
},
517520
},
518521
(err, data, resp) => {
519522
this.metadata = data!;

handwritten/storage/test/bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ describe('Bucket', () => {
897897
const PUBSUB_SERVICE_PATH = '//pubsub.googleapis.com/';
898898
const TOPIC = 'my-topic';
899899
const FULL_TOPIC_NAME =
900-
PUBSUB_SERVICE_PATH + 'projects/{{projectId}}/topics/' + TOPIC;
900+
PUBSUB_SERVICE_PATH + `projects/${PROJECT_ID}/topics/` + TOPIC;
901901

902902
it('should throw an error if a valid topic is not provided', () => {
903903
// eslint-disable-next-line @typescript-eslint/no-floating-promises

handwritten/storage/test/file.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,10 @@ describe('File', () => {
373373
STORAGE.storageTransport.makeRequest = sandbox
374374
.stub()
375375
.callsFake((reqOpts, callback) => {
376+
const body = JSON.parse(reqOpts.body);
376377
assert.strictEqual(reqOpts.method, 'PATCH');
377378
assert.strictEqual(reqOpts.url, '/b/bucket-name//o/file-name.png');
378-
assert.deepStrictEqual(
379-
reqOpts.body.temporaryHold,
380-
options.temporaryHold,
381-
);
379+
assert.deepStrictEqual(body.temporaryHold, options.temporaryHold);
382380
callback(null);
383381
return Promise.resolve();
384382
});

handwritten/storage/test/nodejs-common/service-object.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,11 @@ describe('ServiceObject', () => {
576576
reqOpts,
577577
callback,
578578
) {
579+
const body = JSON.parse(reqOpts.body);
579580
assert.strictEqual(this, serviceObject.storageTransport);
580581
assert.strictEqual(reqOpts.method, 'PATCH');
581582
assert.strictEqual(reqOpts.url, 'base-url/undefined');
582-
assert.deepStrictEqual(reqOpts.body, metadata);
583+
assert.deepStrictEqual(body, metadata);
583584
done();
584585
callback!(null);
585586
return Promise.resolve();

0 commit comments

Comments
 (0)