From 9efd9c5d88fbbefbe646818995231001986eba4b Mon Sep 17 00:00:00 2001 From: Sameena Shaffeeullah Date: Thu, 14 Apr 2022 16:25:33 +0000 Subject: [PATCH 1/2] fix: deleting, getting, and getting metadata for notifications --- .../test-data/retryInvocationMap.json | 5 ++++- src/nodejs-common/service-object.ts | 3 +++ test/nodejs-common/service-object.ts | 22 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/conformance-test/test-data/retryInvocationMap.json b/conformance-test/test-data/retryInvocationMap.json index b3fb6af32..e92e7abd7 100644 --- a/conformance-test/test-data/retryInvocationMap.json +++ b/conformance-test/test-data/retryInvocationMap.json @@ -73,13 +73,16 @@ "createReadStream" ], "storage.notifications.delete": [ + "notificationDelete" ], "storage.notifications.insert": [ "createNotification", "notificationCreate" ], "storage.notifications.get": [ - "notificationExists" + "notificationExists", + "notificationGet", + "notificationGetMetadata" ], "storage.buckets.getIamPolicy": [ "iamGetPolicy" diff --git a/src/nodejs-common/service-object.ts b/src/nodejs-common/service-object.ts index bec9e1e74..af4d0434e 100644 --- a/src/nodejs-common/service-object.ts +++ b/src/nodejs-common/service-object.ts @@ -256,6 +256,9 @@ class ServiceObject extends EventEmitter { const [err, instance] = args; if (!err) { self.metadata = instance.metadata; + if (self.id && instance.metadata) { + self.id = instance.metadata.id; + } args[1] = self; // replace the created `instance` with this one. } callback!(...(args as {} as [Error, T])); diff --git a/test/nodejs-common/service-object.ts b/test/nodejs-common/service-object.ts index 0c143f200..70801b025 100644 --- a/test/nodejs-common/service-object.ts +++ b/test/nodejs-common/service-object.ts @@ -214,6 +214,28 @@ describe('ServiceObject', () => { serviceObject.create(done); }); + it('should update id with metadata id', done => { + const config = extend({}, CONFIG, { + createMethod, + }); + const options = {}; + + function createMethod( + id: string, + options_: {}, + callback: (err: Error | null, a: {}, b: {}) => void + ) { + assert.strictEqual(id, config.id); + assert.strictEqual(options_, options); + callback(null, {metadata: {id: 14}}, {}); + } + + const serviceObject = new ServiceObject(config); + serviceObject.create(options); + assert.strictEqual(serviceObject.id, 14); + done(); + }); + it('should pass error to callback', done => { const config = extend({}, CONFIG, {createMethod}); const options = {}; From 760ad53483a18a263f8075efba2ef9a3aa19f6f2 Mon Sep 17 00:00:00 2001 From: Sameena Shaffeeullah Date: Thu, 14 Apr 2022 16:28:38 +0000 Subject: [PATCH 2/2] removed test added by bigquery when we first reverted this change --- test/nodejs-common/service-object.ts | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/test/nodejs-common/service-object.ts b/test/nodejs-common/service-object.ts index 70801b025..518c08a5e 100644 --- a/test/nodejs-common/service-object.ts +++ b/test/nodejs-common/service-object.ts @@ -176,28 +176,6 @@ describe('ServiceObject', () => { serviceObject.create(options, done); }); - it('should not change id', done => { - const config = extend({}, CONFIG, { - createMethod, - }); - const options = {}; - - function createMethod( - id: string, - options_: {}, - callback: (err: Error | null, a: {}, b: {}) => void - ) { - assert.strictEqual(id, config.id); - assert.strictEqual(options_, options); - callback(null, {metadata: {id: 14}}, {}); - } - - const serviceObject = new ServiceObject(config); - serviceObject.create(options); - assert.notStrictEqual(serviceObject.id, 14); - done(); - }); - it('should not require options', done => { const config = extend({}, CONFIG, { createMethod,