Skip to content

Commit 3c564f9

Browse files
committed
Prepare testing server with many users
1 parent ecd9275 commit 3c564f9

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ node_modules
1313
/test/*/build
1414
/test/*/.firebaserc
1515
/test/*/.env
16+
/test/*/secrets
1617

1718
# Firebase
1819
firebase-debug.log

test/server/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
"firebase-admin": "^10.2.0",
1414
"firebase-functions": "^3.21.2",
1515
"firebase-tools": "^11.0.1"
16+
},
17+
"scripts": {
18+
"seedUsers": "env GOOGLE_APPLICATION_CREDENTIALS=secrets/backup-fire-playground-alt.json node scripts/seedUsers.js"
1619
}
1720
}

test/server/scripts/seedUsers.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const admin = require('firebase-admin')
2+
3+
admin.initializeApp()
4+
5+
const number = parseInt(process.env.NUMBER)
6+
if (isNaN(number))
7+
throw new Error('The NUMBER environment variable must be a number')
8+
9+
const auth = admin.auth()
10+
11+
async function main() {
12+
for (let bunch = 0; bunch < number; bunch++) {
13+
console.log(`=== Creating users bunch #${bunch} ===`)
14+
15+
await Promise.all(
16+
new Array(100).fill(undefined).map((_, i) => {
17+
const email = `test${bunch}${i}${Date.now()}@backupfire.dev`
18+
19+
console.log(`...creating user #${bunch}/${i} (${email})`)
20+
21+
return auth.createUser({
22+
email,
23+
password: Date.now().toString(),
24+
displayName: 'Sasha Clone',
25+
photoURL:
26+
'https://pbs.twimg.com/profile_images/979030533719064576/rD33B86M_400x400.jpg',
27+
})
28+
})
29+
)
30+
}
31+
}
32+
33+
main()

0 commit comments

Comments
 (0)