44set -e
55
66function usage {
7- echo " Usage: $0 <project_id> [<token>]"
7+ echo " Usage: ${0} <project_id> [<token>]"
88 exit 1
99}
1010
@@ -15,16 +15,12 @@ function usage {
1515# ./integration_test/run_tests.sh chenky-test-proj
1616# Example usage (from root dir) with token:
1717# ./integration_test/run_tests.sh chenky-test-proj $TOKEN
18- if [[ $1 == " " ]]; then
18+ if [[ " ${1} " == " " ]]; then
1919 usage
2020fi
2121
22- TOKEN=" "
23- if [[ $2 != " " ]]; then
24- TOKEN=$2
25- fi
26-
27- PROJECT_ID=$1
22+ PROJECT_ID=" ${1} "
23+ TOKEN=" ${2} "
2824
2925# Directory where this script lives.
3026DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
@@ -35,35 +31,35 @@ function announce {
3531
3632function build_sdk {
3733 announce " Building SDK..."
38- cd $ DIR /..
34+ cd " ${ DIR} /.."
3935 rm -f firebase-functions-* .tgz
4036 npm run build:pack
4137 mv firebase-functions-* .tgz integration_test/functions/firebase-functions.tgz
4238}
4339
4440function pick_node8 {
45- cd $ DIR
41+ cd " ${ DIR} "
4642 cp package.node8.json functions/package.json
4743}
4844
4945function pick_node10 {
50- cd $ DIR
46+ cd " ${ DIR} "
5147 cp package.node10.json functions/package.json
5248}
5349
5450function install_deps {
5551 announce " Installing dependencies..."
56- cd $ DIR /functions
52+ cd " ${ DIR} /functions"
5753 rm -rf node_modules/firebase-functions
5854 npm install
5955}
6056
6157function delete_all_functions {
6258 announce " Deleting all functions in project..."
63- cd $ DIR
59+ cd " ${ DIR} "
6460 # Try to delete, if there are errors it is because the project is already empty,
65- # in that case do nothing.
66- if [[ $ TOKEN == " " ]]; then
61+ # in that case do nothing.
62+ if [[ " ${ TOKEN} " == " " ]]; then
6763 firebase functions:delete callableTests createUserTests databaseTests deleteUserTests firestoreTests integrationTests pubsubTests remoteConfigTests --force --project=$PROJECT_ID || : &
6864 else
6965 firebase functions:delete callableTests createUserTests databaseTests deleteUserTests firestoreTests integrationTests pubsubTests remoteConfigTests --force --project=$PROJECT_ID --token=$TOKEN || : &
@@ -73,40 +69,40 @@ function delete_all_functions {
7369}
7470
7571function deploy {
76- cd $ DIR
72+ cd " ${ DIR} "
7773 ./functions/node_modules/.bin/tsc -p functions/
7874 # Deploy functions, and security rules for database and Firestore. If the deploy fails, retry twice
79- if [[ $ TOKEN == " " ]]; then
80- for i in 1 2 3; do firebase deploy --project=$ PROJECT_ID --only functions,database,firestore && break ; done
75+ if [[ " ${ TOKEN} " == " " ]]; then
76+ for i in 1 2 3; do firebase deploy --project=" ${ PROJECT_ID} " --only functions,database,firestore && break ; done
8177 else
82- for i in 1 2 3; do firebase deploy --project=$ PROJECT_ID --token=$ TOKEN --only functions,database,firestore && break ; done
78+ for i in 1 2 3; do firebase deploy --project=" ${ PROJECT_ID} " --token=" ${ TOKEN} " --only functions,database,firestore && break ; done
8379 fi
8480}
8581
8682function run_tests {
87- announce " Running the integration tests..."
83+ announce " Running integration tests..."
8884
8985 # Construct the URL for the test function. This may change in the future,
9086 # causing this script to start failing, but currently we don't have a very
9187 # reliable way of determining the URL dynamically.
9288 TEST_DOMAIN=" cloudfunctions.net"
93- if [[ $ FIREBASE_FUNCTIONS_URL == " https://preprod-cloudfunctions.sandbox.googleapis.com" ]]; then
89+ if [[ " ${ FIREBASE_FUNCTIONS_URL} " == " https://preprod-cloudfunctions.sandbox.googleapis.com" ]]; then
9490 TEST_DOMAIN=" txcloud.net"
9591 fi
96- TEST_URL=" https://us-central1-$PROJECT_ID . $ TEST_DOMAIN /integrationTests"
97- echo $ TEST_URL
92+ TEST_URL=" https://us-central1-${ PROJECT_ID} . ${ TEST_DOMAIN} /integrationTests"
93+ echo " ${ TEST_URL} "
9894
99- curl --fail $ TEST_URL
95+ curl --fail " ${ TEST_URL} "
10096}
10197
10298function cleanup {
10399 announce " Performing cleanup..."
104100 delete_all_functions
105- rm $ DIR /functions/firebase-functions.tgz
106- rm $ DIR /functions/package.json
107- rm -f $ DIR /functions/firebase-debug.log
108- rm -rf $ DIR /functions/lib
109- rm -rf $ DIR /functions/node_modules
101+ rm " ${ DIR} /functions/firebase-functions.tgz"
102+ rm " ${ DIR} /functions/package.json"
103+ rm -f " ${ DIR} /functions/firebase-debug.log"
104+ rm -rf " ${ DIR} /functions/lib"
105+ rm -rf " ${ DIR} /functions/node_modules"
110106}
111107
112108# Setup
0 commit comments