Skip to content

Commit fb58e19

Browse files
kirstywilliamsexaby73
authored andcommitted
wip: v2 func not deploying
1 parent debd4d5 commit fb58e19

24 files changed

+1556
-379
lines changed

integration_test/functions/src/package.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

integration_test/functions/src/testing.ts

Lines changed: 0 additions & 134 deletions
This file was deleted.

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,38 @@ import * as functions from "firebase-functions";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const databaseRefOnWriteTests: any = functions
6+
export const databaseRefOnCreateTests: any = functions
77
.region(REGION)
88
.database.ref("dbTests/{testId}/start")
9-
.onWrite(async (change, context) => {
9+
.onCreate(async (snapshot, context) => {
1010
const testId = context.params.testId;
11-
if (change.after.val() === null) {
12-
functions.logger.info(`Event for ${testId} is null; presuming data cleanup, so skipping.`);
13-
return;
14-
}
1511

1612
try {
1713
await admin
1814
.firestore()
19-
.collection("databaseRefOnWriteTests")
15+
.collection("databaseRefOnCreateTests")
2016
.doc(testId)
2117
.set(
2218
sanitizeData({
2319
...context,
24-
url: change.after.ref.toString(),
20+
url: snapshot.ref.toString(),
2521
})
2622
);
2723
} catch (error) {
28-
console.error(`Error in Database ref onWrite function for testId: ${testId}`, error);
24+
console.error(`Error in Database ref onCreate function for testId: ${testId}`, error);
2925
}
3026
});
3127

32-
export const databaseRefOnCreateTests: any = functions
28+
export const databaseRefOnDeleteTests: any = functions
3329
.region(REGION)
3430
.database.ref("dbTests/{testId}/start")
35-
.onCreate(async (snapshot, context) => {
31+
.onDelete(async (snapshot, context) => {
3632
const testId = context.params.testId;
3733

3834
try {
3935
await admin
4036
.firestore()
41-
.collection("databaseRefOnCreateTests")
37+
.collection("databaseRefOnDeleteTests")
4238
.doc(testId)
4339
.set(
4440
sanitizeData({
@@ -47,7 +43,7 @@ export const databaseRefOnCreateTests: any = functions
4743
})
4844
);
4945
} catch (error) {
50-
console.error(`Error in Database ref onCreate function for testId: ${testId}`, error);
46+
console.error(`Error in Database ref onDelete function for testId: ${testId}`, error);
5147
}
5248
});
5349

@@ -73,24 +69,28 @@ export const databaseRefOnUpdateTests: any = functions
7369
}
7470
});
7571

76-
export const databaseRefOnDeleteTests: any = functions
72+
export const databaseRefOnWriteTests: any = functions
7773
.region(REGION)
7874
.database.ref("dbTests/{testId}/start")
79-
.onDelete(async (snapshot, context) => {
75+
.onWrite(async (change, context) => {
8076
const testId = context.params.testId;
77+
if (change.after.val() === null) {
78+
functions.logger.info(`Event for ${testId} is null; presuming data cleanup, so skipping.`);
79+
return;
80+
}
8181

8282
try {
8383
await admin
8484
.firestore()
85-
.collection("databaseRefOnDeleteTests")
85+
.collection("databaseRefOnWriteTests")
8686
.doc(testId)
8787
.set(
8888
sanitizeData({
8989
...context,
90-
url: snapshot.ref.toString(),
90+
url: change.after.ref.toString(),
9191
})
9292
);
9393
} catch (error) {
94-
console.error(`Error in Database ref onDelete function for testId: ${testId}`, error);
94+
console.error(`Error in Database ref onWrite function for testId: ${testId}`, error);
9595
}
9696
});

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

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,55 @@ export const firestoreDocumentOnCreateTests: any = functions
88
timeoutSeconds: 540,
99
})
1010
.region(REGION)
11-
.firestore.document("tests/{documentId}")
11+
.firestore.document("tests/{testId}")
1212
.onCreate(async (snapshot, context) => {
13-
const documentId = context.params.documentId;
13+
const testId = context.params.testId;
1414
try {
1515
await admin
1616
.firestore()
1717
.collection("firestoreDocumentOnCreateTests")
18-
.doc(documentId)
18+
.doc(testId)
1919
.set(sanitizeData(context));
2020
} catch (error) {
21-
console.error(
22-
`Error in Firestore document onCreate function for testId: ${documentId}`,
23-
error
24-
);
21+
console.error(`Error in Firestore document onCreate function for testId: ${testId}`, error);
2522
}
2623
});
2724

28-
export const firestoreDocumentOnUpdateTests: any = functions
25+
export const firestoreDocumentOnDeleteTests: any = functions
2926
.runWith({
3027
timeoutSeconds: 540,
3128
})
3229
.region(REGION)
33-
.firestore.document("tests/{documentId}")
34-
.onUpdate(async (change, context) => {
35-
const documentId = context.params.documentId;
30+
.firestore.document("tests/{testId}")
31+
.onDelete(async (snapshot, context) => {
32+
const testId = context.params.testId;
3633
try {
3734
await admin
3835
.firestore()
39-
.collection("firestoreDocumentOnUpdateTests")
40-
.doc(documentId)
36+
.collection("firestoreDocumentOnDeleteTests")
37+
.doc(testId)
4138
.set(sanitizeData(context));
4239
} catch (error) {
43-
console.error(
44-
`Error in Firestore document onUpdate function for testId: ${documentId}`,
45-
error
46-
);
40+
console.error(`Error in Firestore document onDelete function for testId: ${testId}`, error);
4741
}
4842
});
4943

50-
export const firestoreDocumentOnDeleteTests: any = functions
44+
export const firestoreDocumentOnUpdateTests: any = functions
5145
.runWith({
5246
timeoutSeconds: 540,
5347
})
5448
.region(REGION)
55-
.firestore.document("tests/{documentId}")
56-
.onDelete(async (snapshot, context) => {
57-
const documentId = context.params.documentId;
49+
.firestore.document("tests/{testId}")
50+
.onUpdate(async (change, context) => {
51+
const testId = context.params.testId;
5852
try {
5953
await admin
6054
.firestore()
61-
.collection("firestoreDocumentOnDeleteTests")
62-
.doc(documentId)
55+
.collection("firestoreDocumentOnUpdateTests")
56+
.doc(testId)
6357
.set(sanitizeData(context));
6458
} catch (error) {
65-
console.error(
66-
`Error in Firestore document onDelete function for testId: ${documentId}`,
67-
error
68-
);
59+
console.error(`Error in Firestore document onUpdate function for testId: ${testId}`, error);
6960
}
7061
});
7162

@@ -74,19 +65,16 @@ export const firestoreDocumentOnWriteTests: any = functions
7465
timeoutSeconds: 540,
7566
})
7667
.region(REGION)
77-
.firestore.document("tests/{documentId}")
68+
.firestore.document("tests/{testId}")
7869
.onWrite(async (change, context) => {
79-
const documentId = context.params.documentId;
70+
const testId = context.params.testId;
8071
try {
8172
await admin
8273
.firestore()
8374
.collection("firestoreDocumentOnWriteTests")
84-
.doc(documentId)
75+
.doc(testId)
8576
.set(sanitizeData(context));
8677
} catch (error) {
87-
console.error(
88-
`Error in Firestore document onWrite function for testId: ${documentId}`,
89-
error
90-
);
78+
console.error(`Error in Firestore document onWrite function for testId: ${testId}`, error);
9179
}
9280
});

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import * as functions from "firebase-functions";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
// TODO(inlined) use multiple queues to run inline
7-
// Expected message data: { "hello": "world" }
86
export const pubsubOnPublishTests: any = functions
97
.region(REGION)
108
.pubsub.topic("pubsubTests")

0 commit comments

Comments
 (0)