Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit 451570e

Browse files
authored
fix: deleting, getting, and getting metadata for notifications (#1872)
* fix: deleting, getting, and getting metadata for notifications * removed test added by bigquery when we first reverted this change
1 parent 640f7b0 commit 451570e

3 files changed

Lines changed: 25 additions & 19 deletions

File tree

conformance-test/test-data/retryInvocationMap.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,16 @@
7373
"createReadStream"
7474
],
7575
"storage.notifications.delete": [
76+
"notificationDelete"
7677
],
7778
"storage.notifications.insert": [
7879
"createNotification",
7980
"notificationCreate"
8081
],
8182
"storage.notifications.get": [
82-
"notificationExists"
83+
"notificationExists",
84+
"notificationGet",
85+
"notificationGetMetadata"
8386
],
8487
"storage.buckets.getIamPolicy": [
8588
"iamGetPolicy"

src/nodejs-common/service-object.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ class ServiceObject<T = any> extends EventEmitter {
256256
const [err, instance] = args;
257257
if (!err) {
258258
self.metadata = instance.metadata;
259+
if (self.id && instance.metadata) {
260+
self.id = instance.metadata.id;
261+
}
259262
args[1] = self; // replace the created `instance` with this one.
260263
}
261264
callback!(...(args as {} as [Error, T]));

test/nodejs-common/service-object.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,42 +176,42 @@ describe('ServiceObject', () => {
176176
serviceObject.create(options, done);
177177
});
178178

179-
it('should not change id', done => {
179+
it('should not require options', done => {
180180
const config = extend({}, CONFIG, {
181181
createMethod,
182182
});
183-
const options = {};
184183

185-
function createMethod(
186-
id: string,
187-
options_: {},
188-
callback: (err: Error | null, a: {}, b: {}) => void
189-
) {
184+
function createMethod(id: string, options: Function, callback: Function) {
190185
assert.strictEqual(id, config.id);
191-
assert.strictEqual(options_, options);
192-
callback(null, {metadata: {id: 14}}, {});
186+
assert.strictEqual(typeof options, 'function');
187+
assert.strictEqual(callback, undefined);
188+
options(null, {}, {}); // calls done()
193189
}
194190

195191
const serviceObject = new ServiceObject(config);
196-
serviceObject.create(options);
197-
assert.notStrictEqual(serviceObject.id, 14);
198-
done();
192+
serviceObject.create(done);
199193
});
200194

201-
it('should not require options', done => {
195+
it('should update id with metadata id', done => {
202196
const config = extend({}, CONFIG, {
203197
createMethod,
204198
});
199+
const options = {};
205200

206-
function createMethod(id: string, options: Function, callback: Function) {
201+
function createMethod(
202+
id: string,
203+
options_: {},
204+
callback: (err: Error | null, a: {}, b: {}) => void
205+
) {
207206
assert.strictEqual(id, config.id);
208-
assert.strictEqual(typeof options, 'function');
209-
assert.strictEqual(callback, undefined);
210-
options(null, {}, {}); // calls done()
207+
assert.strictEqual(options_, options);
208+
callback(null, {metadata: {id: 14}}, {});
211209
}
212210

213211
const serviceObject = new ServiceObject(config);
214-
serviceObject.create(done);
212+
serviceObject.create(options);
213+
assert.strictEqual(serviceObject.id, 14);
214+
done();
215215
});
216216

217217
it('should pass error to callback', done => {

0 commit comments

Comments
 (0)