Skip to content

Commit e19414d

Browse files
authored
Remove handler namespace (#1196)
We will no longer support functions.handler namespace from v4 and onward.
1 parent 51e50c6 commit e19414d

File tree

11 files changed

+0
-919
lines changed

11 files changed

+0
-919
lines changed

spec/v1/providers/analytics.spec.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -290,48 +290,6 @@ describe("Analytics Functions", () => {
290290
});
291291
});
292292

293-
describe("handler namespace", () => {
294-
describe("#onLog", () => {
295-
it("should return an empty endpoint", () => {
296-
const cloudFunction = functions.handler.analytics.event.onLog(() => null);
297-
expect(cloudFunction.__endpoint).to.be.undefined;
298-
});
299-
300-
it("should handle an event with the appropriate fields", () => {
301-
const cloudFunction = functions.handler.analytics.event.onLog(
302-
(data: analytics.AnalyticsEvent) => data
303-
);
304-
305-
// The event data delivered over the wire will be the JSON for an AnalyticsEvent:
306-
// https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
307-
const event: Event = {
308-
data: {
309-
userDim: {
310-
userId: "hi!",
311-
},
312-
},
313-
context: {
314-
eventId: "70172329041928",
315-
timestamp: "2018-04-09T07:56:12.975Z",
316-
eventType: "providers/google.firebase.analytics/eventTypes/event.log",
317-
resource: {
318-
service: "app-measurement.com",
319-
name: "projects/project1/events/first_open",
320-
},
321-
},
322-
};
323-
324-
return expect(cloudFunction(event.data, event.context)).to.eventually.deep.equal({
325-
params: {},
326-
user: {
327-
userId: "hi!",
328-
userProperties: {},
329-
},
330-
});
331-
});
332-
});
333-
});
334-
335293
describe("process.env.GCLOUD_PROJECT not set", () => {
336294
it("should not throw if __endpoint is not accessed", () => {
337295
expect(() => analytics.event("event").onLog(() => null)).to.not.throw(Error);

spec/v1/providers/auth.spec.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -251,33 +251,6 @@ describe("Auth Functions", () => {
251251
});
252252
});
253253

254-
describe("handler namespace", () => {
255-
describe("#onCreate", () => {
256-
it("should return an empty endpoint", () => {
257-
const cloudFunction = functions.handler.auth.user.onCreate(() => null);
258-
expect(cloudFunction.__endpoint).to.be.undefined;
259-
});
260-
});
261-
262-
describe("#onDelete", () => {
263-
const cloudFunctionDelete: CloudFunction<UserRecord> = functions.handler.auth.user.onDelete(
264-
(data: UserRecord) => data
265-
);
266-
267-
it("should return an empty endpoint", () => {
268-
const cloudFunction = functions.handler.auth.user.onDelete(() => null);
269-
expect(cloudFunction.__endpoint).to.be.undefined;
270-
});
271-
272-
it("should handle wire format as of v5.0.0 of firebase-admin", () => {
273-
return cloudFunctionDelete(event.data, event.context).then((data: any) => {
274-
expect(data.metadata.creationTime).to.equal("2016-12-15T19:37:37.059Z");
275-
expect(data.metadata.lastSignInTime).to.equal("2017-01-01T00:00:00.000Z");
276-
});
277-
});
278-
});
279-
});
280-
281254
describe("process.env.GCLOUD_PROJECT not set", () => {
282255
it("should not throw if __endpoint is not accessed", () => {
283256
expect(() => auth.user().onCreate(() => null)).to.not.throw(Error);

spec/v1/providers/database.spec.ts

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -292,138 +292,6 @@ describe("Database Functions", () => {
292292
});
293293
});
294294

295-
describe("handler namespace", () => {
296-
describe("#onWrite()", () => {
297-
it("correctly sets __endpoint to undefind", () => {
298-
const cf = functions.handler.database.ref.onWrite(() => null);
299-
expect(cf.__endpoint).to.be.undefined;
300-
});
301-
302-
it("should be able to use the instance entry point", () => {
303-
const func = functions.handler.database.instance.ref.onWrite(() => null);
304-
expect(func.__endpoint).to.be.undefined;
305-
});
306-
307-
it("should return a handler that emits events with a proper DataSnapshot", () => {
308-
const event = {
309-
data: {
310-
data: null,
311-
delta: { foo: "bar" },
312-
},
313-
context: {
314-
eventId: "70172329041928",
315-
eventType: "providers/google.firebase.database/eventTypes/ref.write",
316-
timestamp: "2018-04-09T07:56:12.975Z",
317-
resource: "projects/_/instances/subdomains/refs/users",
318-
},
319-
};
320-
321-
const handler = functions.handler.database.ref.onWrite((change) => {
322-
return expect(change.after.val()).to.deep.equal({ foo: "bar" });
323-
});
324-
325-
return handler(event.data, event.context);
326-
});
327-
});
328-
329-
describe("#onCreate()", () => {
330-
it("correctly sets endpoint to undefined", () => {
331-
const cf = functions.handler.database.ref.onCreate(() => null);
332-
expect(cf.__endpoint).to.be.undefined;
333-
});
334-
335-
it("should be able to use the instance entry point", () => {
336-
const func = functions.handler.database.instance.ref.onCreate(() => null);
337-
expect(func.__endpoint).to.be.undefined;
338-
});
339-
340-
it("should return a handler that emits events with a proper DataSnapshot", () => {
341-
const event = {
342-
data: {
343-
data: null,
344-
delta: { foo: "bar" },
345-
},
346-
context: {
347-
eventId: "70172329041928",
348-
eventType: "providers/google.firebase.database/eventTypes/ref.create",
349-
timestamp: "2018-04-09T07:56:12.975Z",
350-
resource: "projects/_/instances/subdomains/refs/users",
351-
},
352-
};
353-
const handler = functions.handler.database.ref.onCreate((data) => {
354-
return expect(data.val()).to.deep.equal({ foo: "bar" });
355-
});
356-
357-
return handler(event.data, event.context);
358-
});
359-
});
360-
361-
describe("#onUpdate()", () => {
362-
it("correctly sets endpoint to undefined", () => {
363-
const cf = functions.handler.database.ref.onUpdate(() => null);
364-
expect(cf.__endpoint).to.be.undefined;
365-
});
366-
367-
it("should be able to use the instance entry point", () => {
368-
const func = functions.handler.database.instance.ref.onUpdate(() => null);
369-
expect(func.__endpoint).to.be.undefined;
370-
});
371-
372-
it("should return a handler that emits events with a proper DataSnapshot", () => {
373-
const event = {
374-
data: {
375-
data: null,
376-
delta: { foo: "bar" },
377-
},
378-
context: {
379-
eventId: "70172329041928",
380-
eventType: "providers/google.firebase.database/eventTypes/ref.update",
381-
timestamp: "2018-04-09T07:56:12.975Z",
382-
resource: "projects/_/instances/subdomains/refs/users",
383-
},
384-
};
385-
const handler = functions.handler.database.ref.onUpdate((change) => {
386-
return expect(change.after.val()).to.deep.equal({ foo: "bar" });
387-
});
388-
389-
return handler(event.data, event.context);
390-
});
391-
});
392-
393-
describe("#onDelete()", () => {
394-
it("correctly sets endpoint to undefined", () => {
395-
const cf = functions.handler.database.ref.onDelete(() => null);
396-
expect(cf.__endpoint).to.be.undefined;
397-
});
398-
399-
it("should be able to use the instance entry point", () => {
400-
const func = functions.handler.database.instance.ref.onDelete(() => null);
401-
expect(func.__endpoint).to.be.undefined;
402-
});
403-
404-
it("should return a handler that emits events with a proper DataSnapshot", () => {
405-
const event = {
406-
data: {
407-
data: { foo: "bar" },
408-
delta: null,
409-
},
410-
context: {
411-
eventId: "70172329041928",
412-
eventType: "providers/google.firebase.database/eventTypes/ref.delete",
413-
timestamp: "2018-04-09T07:56:12.975Z",
414-
resource: "projects/_/instances/subdomains/refs/users",
415-
},
416-
};
417-
418-
const handler = functions.handler.database.ref.onDelete((data) => {
419-
return expect(data.val()).to.deep.equal({ foo: "bar" });
420-
});
421-
422-
return handler(event.data, event.context);
423-
});
424-
});
425-
});
426-
427295
describe("process.env.FIREBASE_CONFIG not set", () => {
428296
it("should not throw if __endpoint is not accessed", () => {
429297
expect(() => database.ref("/path").onWrite(() => null)).to.not.throw(Error);

spec/v1/providers/firestore.spec.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -250,66 +250,6 @@ describe("Firestore Functions", () => {
250250
}).timeout(5000);
251251
});
252252

253-
describe("handler namespace", () => {
254-
before(() => {
255-
process.env.GCLOUD_PROJECT = "project1";
256-
});
257-
258-
after(() => {
259-
delete process.env.GCLOUD_PROJECT;
260-
});
261-
262-
it('constructs correct data type on "document.write" events', () => {
263-
const testFunction = functions.handler.firestore.document.onWrite((change) => {
264-
expect(change.before.data()).to.deep.equal({
265-
key1: false,
266-
key2: 111,
267-
});
268-
expect(change.before.get("key1")).to.equal(false);
269-
expect(change.after.data()).to.deep.equal({ key1: true, key2: 123 });
270-
expect(change.after.get("key1")).to.equal(true);
271-
return true; // otherwise will get warning about returning undefined
272-
});
273-
const event = constructEvent(createOldValue(), createValue());
274-
return testFunction(event.data, event.context);
275-
}).timeout(5000);
276-
277-
it('constructs correct data type on "document.create" events', () => {
278-
const testFunction = functions.handler.firestore.document.onCreate((data) => {
279-
expect(data.data()).to.deep.equal({ key1: true, key2: 123 });
280-
expect(data.get("key1")).to.equal(true);
281-
return true; // otherwise will get warning about returning undefined
282-
});
283-
const event = constructEvent({}, createValue());
284-
return testFunction(event.data, event.context);
285-
}).timeout(5000);
286-
287-
it('constructs correct data type on "document.update" events', () => {
288-
const testFunction = functions.handler.firestore.document.onUpdate((change) => {
289-
expect(change.before.data()).to.deep.equal({
290-
key1: false,
291-
key2: 111,
292-
});
293-
expect(change.before.get("key1")).to.equal(false);
294-
expect(change.after.data()).to.deep.equal({ key1: true, key2: 123 });
295-
expect(change.after.get("key1")).to.equal(true);
296-
return true; // otherwise will get warning about returning undefined
297-
});
298-
const event = constructEvent(createOldValue(), createValue());
299-
return testFunction(event.data, event.context);
300-
}).timeout(5000);
301-
302-
it('constructs correct data type on "document.delete" events', () => {
303-
const testFunction = functions.handler.firestore.document.onDelete((data) => {
304-
expect(data.data()).to.deep.equal({ key1: false, key2: 111 });
305-
expect(data.get("key1")).to.equal(false);
306-
return true; // otherwise will get warning about returning undefined
307-
});
308-
const event = constructEvent(createOldValue(), {});
309-
return testFunction(event.data, event.context);
310-
}).timeout(5000);
311-
});
312-
313253
describe("SnapshotConstructor", () => {
314254
describe("#data()", () => {
315255
it("should parse int values", () => {

spec/v1/providers/https.spec.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,6 @@ describe("CloudHttpsBuilder", () => {
5757
});
5858
});
5959

60-
describe("handler namespace", () => {
61-
describe("#onRequest", () => {
62-
it("should return an empty trigger", () => {
63-
const result = functions.handler.https.onRequest((req, res) => {
64-
res.send(200);
65-
});
66-
expect(result.__endpoint).to.be.undefined;
67-
});
68-
});
69-
70-
describe("#onCall", () => {
71-
it("should return an empty trigger", () => {
72-
const result = functions.handler.https.onCall(() => null);
73-
expect(result.__endpoint).to.be.undefined;
74-
});
75-
});
76-
});
77-
7860
describe("#onCall", () => {
7961
it("should return a trigger/endpoint with appropriate values", () => {
8062
const result = https.onCall(() => {

spec/v1/providers/pubsub.spec.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -306,80 +306,6 @@ describe("Pubsub Functions", () => {
306306
});
307307
});
308308

309-
describe("handler namespace", () => {
310-
describe("#onPublish", () => {
311-
describe("#topic", () => {
312-
it("should return an empty trigger", () => {
313-
const result = functions.handler.pubsub.topic.onPublish(() => null);
314-
expect(result.__endpoint).to.be.undefined;
315-
});
316-
317-
it("should properly handle a new-style event", () => {
318-
const raw = new Buffer('{"hello":"world"}', "utf8").toString("base64");
319-
const event = {
320-
data: {
321-
data: raw,
322-
attributes: {
323-
foo: "bar",
324-
},
325-
},
326-
context: {
327-
eventId: "70172329041928",
328-
timestamp: "2018-04-09T07:56:12.975Z",
329-
eventType: "google.pubsub.topic.publish",
330-
resource: {
331-
service: "pubsub.googleapis.com",
332-
name: "projects/project1/topics/toppy",
333-
},
334-
},
335-
};
336-
337-
const result = functions.handler.pubsub.topic.onPublish((data) => {
338-
return {
339-
raw: data.data,
340-
json: data.json,
341-
attributes: data.attributes,
342-
};
343-
});
344-
345-
return expect(result(event.data, event.context)).to.eventually.deep.equal({
346-
raw,
347-
json: { hello: "world" },
348-
attributes: { foo: "bar" },
349-
});
350-
});
351-
});
352-
describe("#schedule", () => {
353-
it("should return an empty trigger", () => {
354-
const result = functions.handler.pubsub.schedule.onRun(() => null);
355-
expect(result.__endpoint).to.be.undefined;
356-
});
357-
it("should return a handler with a proper event context", () => {
358-
const raw = new Buffer('{"hello":"world"}', "utf8").toString("base64");
359-
const event = {
360-
data: {
361-
data: raw,
362-
attributes: {
363-
foo: "bar",
364-
},
365-
},
366-
context: {
367-
eventId: "70172329041928",
368-
timestamp: "2018-04-09T07:56:12.975Z",
369-
eventType: "google.pubsub.topic.publish",
370-
resource: {
371-
service: "pubsub.googleapis.com",
372-
name: "projects/project1/topics/toppy",
373-
},
374-
},
375-
};
376-
const result = functions.handler.pubsub.schedule.onRun((context) => context.eventId);
377-
return expect(result(event.data, event.context)).to.eventually.equal("70172329041928");
378-
});
379-
});
380-
});
381-
});
382-
383309
describe("process.env.GCLOUD_PROJECT not set", () => {
384310
it("should not throw if __endpoint is not accessed", () => {
385311
expect(() => pubsub.topic("toppy").onPublish(() => null)).to.not.throw(Error);

0 commit comments

Comments
 (0)