-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for firebase-functions binary (#1028)
Add integration test for firebase-functions binary. The integration setup is more robust than what we had before - it builds and installs the Functions SDK package at the branch commit and try to run the produced binary that ships with the Functions SDK. We also modify the github CI/release script setting to run the integration test as part of its workflow.
- Loading branch information
Showing
21 changed files
with
371 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
exit: true | ||
extension: | ||
- ts | ||
file: | ||
- mocha/setup.ts | ||
package: ./package.json | ||
reporter: spec | ||
require: | ||
- 'ts-node/register' | ||
spec: spec/**/*.spec.ts | ||
- 'source-map-support/register' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as chai from 'chai'; | ||
import * as chaiAsPromised from 'chai-as-promised'; | ||
|
||
chai.use(chaiAsPromised); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -ex # Immediately exit on failure | ||
|
||
# Link the Functions SDK for the testing environment. | ||
npm run build | ||
npm link | ||
|
||
# Link local SDK to all test sources. | ||
for f in scripts/bin-test/sources/*; do | ||
if [ -d "$f" ]; then | ||
(cd "$f" && npm link firebase-functions) | ||
fi | ||
done | ||
|
||
## DEBUG | ||
ls -la scripts/bin-test/sources/commonjs/node_modules | ||
|
||
mocha \ | ||
--file ./scripts/bin-test/mocha-setup.ts \ | ||
./scripts/bin-test/test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const functions = require("firebase-functions"); | ||
|
||
exports.groupedhttp = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.groupedcallable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const functions = require("firebase-functions"); | ||
const functionsv2 = require("firebase-functions/v2"); | ||
|
||
exports.v1http = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v1callable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.v2http = functionsv2.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v2callable = functionsv2.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.g1 = require("./g1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "commonjs-grouped" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const functions = require("firebase-functions"); | ||
const functionsv2 = require("firebase-functions/v2"); | ||
|
||
exports.v1http = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v1callable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.v2http = functionsv2.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v2callable = functionsv2.https.onCall(() => { | ||
return "PASS"; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "commonjs-main", | ||
"main": "functions.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const functions = require("firebase-functions"); | ||
const functionsv2 = require("firebase-functions/v2"); | ||
|
||
exports.v1http = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v1callable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.v2http = functionsv2.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v2callable = functionsv2.https.onCall(() => { | ||
return "PASS"; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "commonjs" | ||
} |
4 changes: 2 additions & 2 deletions
4
spec/fixtures/sources/esm-ext/index.mjs → scripts/bin-test/sources/esm-ext/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
spec/fixtures/sources/esm-main/functions.js → ...ts/bin-test/sources/esm-main/functions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
spec/fixtures/sources/esm/index.js → scripts/bin-test/sources/esm/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.