Skip to content

Commit d877483

Browse files
committed
Merge branch 'launch.next' into dl-handler-no-mo
2 parents 3241eaf + 9ab2d6d commit d877483

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2217
-2985
lines changed

.eslintignore

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
coverage
2-
dev
31
lib
2+
dev
43
node_modules
5-
docgen
6-
v1
7-
v2
8-
logger
9-
dist
10-
spec/fixtures
11-
scripts/**/*.js
4+
/coverage/
5+
/docgen/
6+
/v1/
7+
/v2/
8+
/logger/
9+
/dist/
10+
/spec/fixtures
11+
/scripts/**/*.js
Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { expectEq, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { expectEq, TestSuite } from "../testing";
55
import UserMetadata = admin.auth.UserRecord;
66

77
export const createUserTests: any = functions
@@ -11,35 +11,26 @@ export const createUserTests: any = functions
1111
const testId: string = u.displayName;
1212
functions.logger.info(`testId is ${testId}`);
1313

14-
return new TestSuite<UserMetadata>('auth user onCreate')
15-
.it('should have a project as resource', (user, context) =>
16-
expectEq(
17-
context.resource.name,
18-
`projects/${process.env.GCLOUD_PROJECT}`
19-
)
14+
return new TestSuite<UserMetadata>("auth user onCreate")
15+
.it("should have a project as resource", (user, context) =>
16+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
2017
)
2118

22-
.it('should not have a path', (user, context) =>
23-
expectEq((context as any).path, undefined)
24-
)
19+
.it("should not have a path", (user, context) => expectEq((context as any).path, undefined))
2520

26-
.it('should have the correct eventType', (user, context) =>
27-
expectEq(context.eventType, 'google.firebase.auth.user.create')
21+
.it("should have the correct eventType", (user, context) =>
22+
expectEq(context.eventType, "google.firebase.auth.user.create")
2823
)
2924

30-
.it('should have an eventId', (user, context) => context.eventId)
25+
.it("should have an eventId", (user, context) => context.eventId)
3126

32-
.it('should have a timestamp', (user, context) => context.timestamp)
27+
.it("should have a timestamp", (user, context) => context.timestamp)
3328

34-
.it('should not have auth', (user, context) =>
35-
expectEq((context as any).auth, undefined)
36-
)
29+
.it("should not have auth", (user, context) => expectEq((context as any).auth, undefined))
3730

38-
.it('should not have action', (user, context) =>
39-
expectEq((context as any).action, undefined)
40-
)
31+
.it("should not have action", (user, context) => expectEq((context as any).action, undefined))
4132

42-
.it('should have properly defined meta', (user, context) => user.metadata)
33+
.it("should have properly defined meta", (user) => user.metadata)
4334

4435
.run(testId, u, c);
4536
});
@@ -51,33 +42,24 @@ export const deleteUserTests: any = functions
5142
const testId: string = u.displayName;
5243
functions.logger.info(`testId is ${testId}`);
5344

54-
return new TestSuite<UserMetadata>('auth user onDelete')
55-
.it('should have a project as resource', (user, context) =>
56-
expectEq(
57-
context.resource.name,
58-
`projects/${process.env.GCLOUD_PROJECT}`
59-
)
45+
return new TestSuite<UserMetadata>("auth user onDelete")
46+
.it("should have a project as resource", (user, context) =>
47+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
6048
)
6149

62-
.it('should not have a path', (user, context) =>
63-
expectEq((context as any).path, undefined)
64-
)
50+
.it("should not have a path", (user, context) => expectEq((context as any).path, undefined))
6551

66-
.it('should have the correct eventType', (user, context) =>
67-
expectEq(context.eventType, 'google.firebase.auth.user.delete')
52+
.it("should have the correct eventType", (user, context) =>
53+
expectEq(context.eventType, "google.firebase.auth.user.delete")
6854
)
6955

70-
.it('should have an eventId', (user, context) => context.eventId)
56+
.it("should have an eventId", (user, context) => context.eventId)
7157

72-
.it('should have a timestamp', (user, context) => context.timestamp)
58+
.it("should have a timestamp", (user, context) => context.timestamp)
7359

74-
.it('should not have auth', (user, context) =>
75-
expectEq((context as any).auth, undefined)
76-
)
60+
.it("should not have auth", (user, context) => expectEq((context as any).auth, undefined))
7761

78-
.it('should not have action', (user, context) =>
79-
expectEq((context as any).action, undefined)
80-
)
62+
.it("should not have action", (user, context) => expectEq((context as any).action, undefined))
8163

8264
.run(testId, u, c);
8365
});
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { expectEq, expectMatches, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { expectEq, expectMatches, TestSuite } from "../testing";
55
import DataSnapshot = admin.database.DataSnapshot;
66

7-
const testIdFieldName = 'testId';
7+
const testIdFieldName = "testId";
88

99
export const databaseTests: any = functions
1010
.region(REGION)
11-
.database.ref('dbTests/{testId}/start')
11+
.database.ref("dbTests/{testId}/start")
1212
.onWrite((ch, ctx) => {
1313
if (ch.after.val() === null) {
1414
functions.logger.info(
15-
'Event for ' +
16-
ctx.params[testIdFieldName] +
17-
' is null; presuming data cleanup, so skipping.'
15+
`Event for ${ctx.params[testIdFieldName]} is null; presuming data cleanup, so skipping.`
1816
);
1917
return;
2018
}
2119

22-
return new TestSuite<functions.Change<DataSnapshot>>('database ref onWrite')
20+
return new TestSuite<functions.Change<DataSnapshot>>("database ref onWrite")
2321

24-
.it(
25-
'should not have event.app',
26-
(change, context) => !(context as any).app
27-
)
22+
.it("should not have event.app", (change, context) => !(context as any).app)
2823

29-
.it('should give refs access to admin data', (change) =>
24+
.it("should give refs access to admin data", (change) =>
3025
change.after.ref.parent
31-
.child('adminOnly')
26+
.child("adminOnly")
3227
.update({ allowed: 1 })
3328
.then(() => true)
3429
)
3530

36-
.it('should have a correct ref url', (change) => {
31+
.it("should have a correct ref url", (change) => {
3732
const url = change.after.ref.toString();
3833
return Promise.resolve()
3934
.then(() => {
@@ -49,7 +44,7 @@ export const databaseTests: any = functions
4944
});
5045
})
5146

52-
.it('should have refs resources', (change, context) =>
47+
.it("should have refs resources", (change, context) =>
5348
expectMatches(
5449
context.resource.name,
5550
new RegExp(
@@ -58,25 +53,23 @@ export const databaseTests: any = functions
5853
)
5954
)
6055

61-
.it('should not include path', (change, context) =>
56+
.it("should not include path", (change, context) =>
6257
expectEq((context as any).path, undefined)
6358
)
6459

65-
.it('should have the right eventType', (change, context) =>
66-
expectEq(context.eventType, 'google.firebase.database.ref.write')
60+
.it("should have the right eventType", (change, context) =>
61+
expectEq(context.eventType, "google.firebase.database.ref.write")
6762
)
6863

69-
.it('should have eventId', (change, context) => context.eventId)
64+
.it("should have eventId", (change, context) => context.eventId)
7065

71-
.it('should have timestamp', (change, context) => context.timestamp)
66+
.it("should have timestamp", (change, context) => context.timestamp)
7267

73-
.it('should not have action', (change, context) =>
68+
.it("should not have action", (change, context) =>
7469
expectEq((context as any).action, undefined)
7570
)
7671

77-
.it('should have admin authType', (change, context) =>
78-
expectEq(context.authType, 'ADMIN')
79-
)
72+
.it("should have admin authType", (change, context) => expectEq(context.authType, "ADMIN"))
8073

8174
.run(ctx.params[testIdFieldName], ch, ctx);
8275
});

integration_test/functions/src/v1/firestore-tests.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import * as admin from 'firebase-admin';
2-
import * as functions from 'firebase-functions';
3-
import { REGION } from '../region';
4-
import { expectDeepEq, expectEq, TestSuite } from '../testing';
1+
import * as admin from "firebase-admin";
2+
import * as functions from "firebase-functions";
3+
import { REGION } from "../region";
4+
import { expectDeepEq, expectEq, TestSuite } from "../testing";
55
import DocumentSnapshot = admin.firestore.DocumentSnapshot;
66

7-
const testIdFieldName = 'documentId';
7+
const testIdFieldName = "documentId";
88

99
export const firestoreTests: any = functions
1010
.runWith({
1111
timeoutSeconds: 540,
1212
})
1313
.region(REGION)
14-
.firestore.document('tests/{documentId}')
14+
.firestore.document("tests/{documentId}")
1515
.onCreate((s, c) => {
16-
return new TestSuite<DocumentSnapshot>('firestore document onWrite')
16+
return new TestSuite<DocumentSnapshot>("firestore document onWrite")
1717

18-
.it('should not have event.app', (snap, context) => !(context as any).app)
18+
.it("should not have event.app", (snap, context) => !(context as any).app)
1919

20-
.it('should give refs write access', (snap) =>
20+
.it("should give refs write access", (snap) =>
2121
snap.ref.set({ allowed: 1 }, { merge: true }).then(() => true)
2222
)
2323

24-
.it('should have well-formatted resource', (snap, context) =>
24+
.it("should have well-formatted resource", (snap, context) =>
2525
expectEq(
2626
context.resource.name,
2727
`projects/${process.env.GCLOUD_PROJECT}/databases/(default)/documents/tests/${context.params.documentId}`
2828
)
2929
)
3030

31-
.it('should have the right eventType', (snap, context) =>
32-
expectEq(context.eventType, 'google.firestore.document.create')
31+
.it("should have the right eventType", (snap, context) =>
32+
expectEq(context.eventType, "google.firestore.document.create")
3333
)
3434

35-
.it('should have eventId', (snap, context) => context.eventId)
35+
.it("should have eventId", (snap, context) => context.eventId)
3636

37-
.it('should have timestamp', (snap, context) => context.timestamp)
37+
.it("should have timestamp", (snap, context) => context.timestamp)
3838

39-
.it('should have the correct data', (snap, context) =>
39+
.it("should have the correct data", (snap, context) =>
4040
expectDeepEq(snap.data(), { test: context.params.documentId })
4141
)
4242

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import * as functions from 'firebase-functions';
2-
import { REGION } from '../region';
3-
import { expectEq, TestSuite } from '../testing';
1+
import * as functions from "firebase-functions";
2+
import { REGION } from "../region";
3+
import { expectEq, TestSuite } from "../testing";
44

55
export const callableTests: any = functions
6-
.runWith({ invoker: 'private' })
6+
.runWith({ invoker: "private" })
77
.region(REGION)
88
.https.onCall((d) => {
9-
return new TestSuite('https onCall')
10-
.it('should have the correct data', (data: any) =>
11-
expectEq(data?.foo, 'bar')
12-
)
9+
return new TestSuite("https onCall")
10+
.it("should have the correct data", (data: any) => expectEq(data?.foo, "bar"))
1311
.run(d.testId, d);
1412
});
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export * from './pubsub-tests';
2-
export * from './database-tests';
3-
export * from './auth-tests';
4-
export * from './firestore-tests';
5-
export * from './https-tests';
6-
export * from './remoteConfig-tests';
7-
export * from './storage-tests';
8-
export * from './testLab-tests';
1+
export * from "./pubsub-tests";
2+
export * from "./database-tests";
3+
export * from "./auth-tests";
4+
export * from "./firestore-tests";
5+
export * from "./https-tests";
6+
export * from "./remoteConfig-tests";
7+
export * from "./storage-tests";
8+
export * from "./testLab-tests";

0 commit comments

Comments
 (0)