4
4
set -e
5
5
6
6
function usage {
7
- echo " Usage: $0 <project_id> [<token>]"
7
+ echo " Usage: ${0} <project_id> [<token>]"
8
8
exit 1
9
9
}
10
10
@@ -15,16 +15,12 @@ function usage {
15
15
# ./integration_test/run_tests.sh chenky-test-proj
16
16
# Example usage (from root dir) with token:
17
17
# ./integration_test/run_tests.sh chenky-test-proj $TOKEN
18
- if [[ $1 == " " ]]; then
18
+ if [[ " ${1} " == " " ]]; then
19
19
usage
20
20
fi
21
21
22
- TOKEN=" "
23
- if [[ $2 != " " ]]; then
24
- TOKEN=$2
25
- fi
26
-
27
- PROJECT_ID=$1
22
+ PROJECT_ID=" ${1} "
23
+ TOKEN=" ${2} "
28
24
29
25
# Directory where this script lives.
30
26
DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
@@ -35,35 +31,35 @@ function announce {
35
31
36
32
function build_sdk {
37
33
announce " Building SDK..."
38
- cd $ DIR /..
34
+ cd " ${ DIR} /.."
39
35
rm -f firebase-functions-* .tgz
40
36
npm run build:pack
41
37
mv firebase-functions-* .tgz integration_test/functions/firebase-functions.tgz
42
38
}
43
39
44
40
function pick_node8 {
45
- cd $ DIR
41
+ cd " ${ DIR} "
46
42
cp package.node8.json functions/package.json
47
43
}
48
44
49
45
function pick_node10 {
50
- cd $ DIR
46
+ cd " ${ DIR} "
51
47
cp package.node10.json functions/package.json
52
48
}
53
49
54
50
function install_deps {
55
51
announce " Installing dependencies..."
56
- cd $ DIR /functions
52
+ cd " ${ DIR} /functions"
57
53
rm -rf node_modules/firebase-functions
58
54
npm install
59
55
}
60
56
61
57
function delete_all_functions {
62
58
announce " Deleting all functions in project..."
63
- cd $ DIR
59
+ cd " ${ DIR} "
64
60
# 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
67
63
firebase functions:delete callableTests createUserTests databaseTests deleteUserTests firestoreTests integrationTests pubsubTests remoteConfigTests --force --project=$PROJECT_ID || : &
68
64
else
69
65
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 {
73
69
}
74
70
75
71
function deploy {
76
- cd $ DIR
72
+ cd " ${ DIR} "
77
73
./functions/node_modules/.bin/tsc -p functions/
78
74
# 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
81
77
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
83
79
fi
84
80
}
85
81
86
82
function run_tests {
87
- announce " Running the integration tests..."
83
+ announce " Running integration tests..."
88
84
89
85
# Construct the URL for the test function. This may change in the future,
90
86
# causing this script to start failing, but currently we don't have a very
91
87
# reliable way of determining the URL dynamically.
92
88
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
94
90
TEST_DOMAIN=" txcloud.net"
95
91
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} "
98
94
99
- curl --fail $ TEST_URL
95
+ curl --fail " ${ TEST_URL} "
100
96
}
101
97
102
98
function cleanup {
103
99
announce " Performing cleanup..."
104
100
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"
110
106
}
111
107
112
108
# Setup
0 commit comments