Skip to content

Commit

Permalink
wip: Integration tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Oct 7, 2024
1 parent 6c22d40 commit cbf0840
Show file tree
Hide file tree
Showing 35 changed files with 2,406 additions and 2,926 deletions.
16 changes: 16 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
steps:
- name: "node:18"
entrypoint: "npm"
dir: "integration_test"
args: ["install"]
- name: "node:18"
entrypoint: "npx"
dir: "integration_test"
args: ["firebase", "use", "cf3-integration-tests-d7be6"]
- name: "node:18"
entrypoint: "npm"
dir: "integration_test"
args: ["start"]

options:
defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET
3 changes: 3 additions & 0 deletions integration_test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ node_modules/
serviceAccount.json
functions.yaml
functions/src/package.json
functions/package/

.nvmrc
3 changes: 1 addition & 2 deletions integration_test/functions/src/region.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// TODO: Add back support for selecting region for integration test once params is ready.
export const REGION = "us-central1";
export const REGION = process.env.REGION;
80 changes: 40 additions & 40 deletions integration_test/functions/src/v1/storage-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@ import * as functions from "firebase-functions";
import { REGION } from "../region";
import { sanitizeData } from "../utils";

export const storageOnDeleteTests: any = functions
.runWith({
timeoutSeconds: 540,
})
.region(REGION)
.storage.bucket()
.object()
.onDelete(async (object, context) => {
const testId = object.name?.split(".")[0];
if (!testId) {
functions.logger.error("TestId not found for storage object delete");
return;
}

await admin
.firestore()
.collection("storageOnDeleteTests")
.doc(testId)
.set(sanitizeData(context));
});
// export const storageOnDeleteTests: any = functions
// .runWith({
// timeoutSeconds: 540,
// })
// .region(REGION)
// .storage.bucket()
// .object()
// .onDelete(async (object, context) => {
// const testId = object.name?.split(".")[0];
// if (!testId) {
// functions.logger.error("TestId not found for storage object delete");
// return;
// }
//
// await admin
// .firestore()
// .collection("storageOnDeleteTests")
// .doc(testId)
// .set(sanitizeData(context));
// });

export const storageOnFinalizeTests: any = functions
.runWith({
timeoutSeconds: 540,
})
.region(REGION)
.storage.bucket()
.object()
.onFinalize(async (object, context) => {
const testId = object.name?.split(".")[0];
if (!testId) {
functions.logger.error("TestId not found for storage object finalize");
return;
}

await admin
.firestore()
.collection("storageOnFinalizeTests")
.doc(testId)
.set(sanitizeData(context));
});
// export const storageOnFinalizeTests: any = functions
// .runWith({
// timeoutSeconds: 540,
// })
// .region(REGION)
// .storage.bucket()
// .object()
// .onFinalize(async (object, context) => {
// const testId = object.name?.split(".")[0];
// if (!testId) {
// functions.logger.error("TestId not found for storage object finalize");
// return;
// }
//
// await admin
// .firestore()
// .collection("storageOnFinalizeTests")
// .doc(testId)
// .set(sanitizeData(context));
// });

export const storageOnMetadataUpdateTests: any = functions
.runWith({
Expand Down
10 changes: 5 additions & 5 deletions integration_test/functions/src/v2/firestore-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
onDocumentUpdated,
onDocumentWritten,
} from "firebase-functions/v2/firestore";
import { REGION } from "../region";
import { sanitizeData } from "../utils";
import { FIRESTORE_REGION } from "../region";

export const firestoreOnDocumentCreatedTests = onDocumentCreated(
{
document: "tests/{documentId}",
region: REGION,
region: FIRESTORE_REGION,
timeoutSeconds: 540,
},
async (event) => {
Expand All @@ -37,7 +37,7 @@ export const firestoreOnDocumentCreatedTests = onDocumentCreated(
export const firestoreOnDocumentDeletedTests = onDocumentDeleted(
{
document: "tests/{documentId}",
region: REGION,
region: FIRESTORE_REGION,
timeoutSeconds: 540,
},
async (event) => {
Expand All @@ -62,7 +62,7 @@ export const firestoreOnDocumentDeletedTests = onDocumentDeleted(
export const firestoreOnDocumentUpdatedTests = onDocumentUpdated(
{
document: "tests/{documentId}",
region: REGION,
region: FIRESTORE_REGION,
timeoutSeconds: 540,
},
async (event) => {
Expand All @@ -87,7 +87,7 @@ export const firestoreOnDocumentUpdatedTests = onDocumentUpdated(
export const firestoreOnDocumentWrittenTests = onDocumentWritten(
{
document: "tests/{documentId}",
region: REGION,
region: FIRESTORE_REGION,
timeoutSeconds: 540,
},
async (event) => {
Expand Down
9 changes: 9 additions & 0 deletions integration_test/integration_test.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Loading

0 comments on commit cbf0840

Please sign in to comment.