-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfirebase_firebase-functions.ts
50 lines (40 loc) · 1.37 KB
/
firebase_firebase-functions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// All: 9 JSNice: 7 LambdaNet: 7
import * as nock from 'nock';
function mockRCVariableFetch(
projectId: string,
varName: string,
data,
token: string = 'thetoken'
): nock.Scope {
let mock: nock.Scope = nock('https://runtimeconfig.googleapis.com')
.get(`/v1beta1/projects/${projectId}/configs/firebase/variables/${varName}`);
if (token) {
mock = mock.matchHeader('Authorization', `Bearer ${token}`);
}
return mock.reply(200, {text: JSON.stringify(data)});
}
function mockMetaVariableWatch(
projectId: string,
data,
token: string,
updateTime: string
): nock.Scope {
let mock: nock.Scope = nock('https://runtimeconfig.googleapis.com')
.post(`/v1beta1/projects/${projectId}/configs/firebase/variables/meta:watch`);
if (token) {
mock = mock.matchHeader('Authorization', `Bearer ${token}`);
}
return mock.reply(200, {
updateTime,
state: 'UPDATED',
text: JSON.stringify(data),
});
}
function mockMetaVariableWatchTimeout(projectId: string, delay: number, token?: string): nock.Scope {
let mock: nock.Scope = nock('https://runtimeconfig.googleapis.com')
.post(`/v1beta1/projects/${projectId}/configs/firebase/variables/meta:watch`);
if (token) {
mock = mock.matchHeader('Authorization', `Bearer ${token}`);
}
return mock.delay(delay).reply(502);
}