Skip to content

Commit cbf0840

Browse files
committed
wip: Integration tests fixes
1 parent 6c22d40 commit cbf0840

35 files changed

+2406
-2926
lines changed

cloudbuild.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
steps:
2+
- name: "node:18"
3+
entrypoint: "npm"
4+
dir: "integration_test"
5+
args: ["install"]
6+
- name: "node:18"
7+
entrypoint: "npx"
8+
dir: "integration_test"
9+
args: ["firebase", "use", "cf3-integration-tests-d7be6"]
10+
- name: "node:18"
11+
entrypoint: "npm"
12+
dir: "integration_test"
13+
args: ["start"]
14+
15+
options:
16+
defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET

integration_test/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ node_modules/
7070
serviceAccount.json
7171
functions.yaml
7272
functions/src/package.json
73+
functions/package/
74+
75+
.nvmrc
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// TODO: Add back support for selecting region for integration test once params is ready.
2-
export const REGION = "us-central1";
1+
export const REGION = process.env.REGION;

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

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

6-
export const storageOnDeleteTests: any = functions
7-
.runWith({
8-
timeoutSeconds: 540,
9-
})
10-
.region(REGION)
11-
.storage.bucket()
12-
.object()
13-
.onDelete(async (object, context) => {
14-
const testId = object.name?.split(".")[0];
15-
if (!testId) {
16-
functions.logger.error("TestId not found for storage object delete");
17-
return;
18-
}
19-
20-
await admin
21-
.firestore()
22-
.collection("storageOnDeleteTests")
23-
.doc(testId)
24-
.set(sanitizeData(context));
25-
});
6+
// export const storageOnDeleteTests: any = functions
7+
// .runWith({
8+
// timeoutSeconds: 540,
9+
// })
10+
// .region(REGION)
11+
// .storage.bucket()
12+
// .object()
13+
// .onDelete(async (object, context) => {
14+
// const testId = object.name?.split(".")[0];
15+
// if (!testId) {
16+
// functions.logger.error("TestId not found for storage object delete");
17+
// return;
18+
// }
19+
//
20+
// await admin
21+
// .firestore()
22+
// .collection("storageOnDeleteTests")
23+
// .doc(testId)
24+
// .set(sanitizeData(context));
25+
// });
2626

27-
export const storageOnFinalizeTests: any = functions
28-
.runWith({
29-
timeoutSeconds: 540,
30-
})
31-
.region(REGION)
32-
.storage.bucket()
33-
.object()
34-
.onFinalize(async (object, context) => {
35-
const testId = object.name?.split(".")[0];
36-
if (!testId) {
37-
functions.logger.error("TestId not found for storage object finalize");
38-
return;
39-
}
40-
41-
await admin
42-
.firestore()
43-
.collection("storageOnFinalizeTests")
44-
.doc(testId)
45-
.set(sanitizeData(context));
46-
});
27+
// export const storageOnFinalizeTests: any = functions
28+
// .runWith({
29+
// timeoutSeconds: 540,
30+
// })
31+
// .region(REGION)
32+
// .storage.bucket()
33+
// .object()
34+
// .onFinalize(async (object, context) => {
35+
// const testId = object.name?.split(".")[0];
36+
// if (!testId) {
37+
// functions.logger.error("TestId not found for storage object finalize");
38+
// return;
39+
// }
40+
//
41+
// await admin
42+
// .firestore()
43+
// .collection("storageOnFinalizeTests")
44+
// .doc(testId)
45+
// .set(sanitizeData(context));
46+
// });
4747

4848
export const storageOnMetadataUpdateTests: any = functions
4949
.runWith({

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {
66
onDocumentUpdated,
77
onDocumentWritten,
88
} from "firebase-functions/v2/firestore";
9-
import { REGION } from "../region";
109
import { sanitizeData } from "../utils";
10+
import { FIRESTORE_REGION } from "../region";
1111

1212
export const firestoreOnDocumentCreatedTests = onDocumentCreated(
1313
{
1414
document: "tests/{documentId}",
15-
region: REGION,
15+
region: FIRESTORE_REGION,
1616
timeoutSeconds: 540,
1717
},
1818
async (event) => {
@@ -37,7 +37,7 @@ export const firestoreOnDocumentCreatedTests = onDocumentCreated(
3737
export const firestoreOnDocumentDeletedTests = onDocumentDeleted(
3838
{
3939
document: "tests/{documentId}",
40-
region: REGION,
40+
region: FIRESTORE_REGION,
4141
timeoutSeconds: 540,
4242
},
4343
async (event) => {
@@ -62,7 +62,7 @@ export const firestoreOnDocumentDeletedTests = onDocumentDeleted(
6262
export const firestoreOnDocumentUpdatedTests = onDocumentUpdated(
6363
{
6464
document: "tests/{documentId}",
65-
region: REGION,
65+
region: FIRESTORE_REGION,
6666
timeoutSeconds: 540,
6767
},
6868
async (event) => {
@@ -87,7 +87,7 @@ export const firestoreOnDocumentUpdatedTests = onDocumentUpdated(
8787
export const firestoreOnDocumentWrittenTests = onDocumentWritten(
8888
{
8989
document: "tests/{documentId}",
90-
region: REGION,
90+
region: FIRESTORE_REGION,
9191
timeoutSeconds: 540,
9292
},
9393
async (event) => {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="WEB_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$" />
6+
<orderEntry type="inheritedJdk" />
7+
<orderEntry type="sourceFolder" forTests="false" />
8+
</component>
9+
</module>

0 commit comments

Comments
 (0)