Skip to content

Commit 78dae73

Browse files
authored
Add CPU option. Rip out deprecated apiVersion (#1077)
* Add CPU option. Rip out deprecated apiVersion * Formatter * PR feedback
1 parent 19d7d6e commit 78dae73

File tree

33 files changed

+120
-167
lines changed

33 files changed

+120
-167
lines changed

integration_test/functions/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { PubSub } from '@google-cloud/pubsub';
22
import { Request, Response } from 'express';
3-
import fetch from 'node-fetch';
43
import * as admin from 'firebase-admin';
54
import * as functions from 'firebase-functions';
65
import * as fs from 'fs';
6+
import fetch from 'node-fetch';
77

88
import * as v1 from './v1';
99
import * as v2 from './v2';
@@ -15,8 +15,8 @@ const getNumTests = (m: object): number => {
1515
const numTests = getNumTests(v1) + getNumTests(v2);
1616
export { v1, v2 };
1717

18-
import * as testLab from './v1/testLab-utils';
1918
import { REGION } from './region';
19+
import * as testLab from './v1/testLab-utils';
2020

2121
const firebaseConfig = JSON.parse(process.env.FIREBASE_CONFIG);
2222
admin.initializeApp();
@@ -115,7 +115,7 @@ async function updateRemoteConfig(
115115
}
116116
}
117117

118-
function v1Tests(testId: string, accessToken: string): Promise<void>[] {
118+
function v1Tests(testId: string, accessToken: string): Array<Promise<void>> {
119119
return [
120120
// A database write to trigger the Firebase Realtime Database tests.
121121
admin
@@ -159,7 +159,7 @@ function v1Tests(testId: string, accessToken: string): Promise<void>[] {
159159
];
160160
}
161161

162-
function v2Tests(testId: string, accessToken: string): Promise<void>[] {
162+
function v2Tests(testId: string, accessToken: string): Array<Promise<void>> {
163163
return [
164164
// Invoke a callable HTTPS trigger.
165165
callV2HttpsTrigger('v2-callabletests', { foo: 'bar', testId }, accessToken),

integration_test/functions/src/v1/auth-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as admin from 'firebase-admin';
22
import * as functions from 'firebase-functions';
3-
import { expectEq, TestSuite } from '../testing';
43
import { REGION } from '../region';
4+
import { expectEq, TestSuite } from '../testing';
55
import UserMetadata = admin.auth.UserRecord;
66

77
export const createUserTests: any = functions

integration_test/functions/src/v1/database-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as admin from 'firebase-admin';
22
import * as functions from 'firebase-functions';
3-
import { expectEq, expectMatches, TestSuite } from '../testing';
43
import { REGION } from '../region';
4+
import { expectEq, expectMatches, TestSuite } from '../testing';
55
import DataSnapshot = admin.database.DataSnapshot;
66

77
const testIdFieldName = 'testId';

integration_test/functions/src/v1/firestore-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as admin from 'firebase-admin';
22
import * as functions from 'firebase-functions';
3-
import { expectDeepEq, expectEq, TestSuite } from '../testing';
43
import { REGION } from '../region';
4+
import { expectDeepEq, expectEq, TestSuite } from '../testing';
55
import DocumentSnapshot = admin.firestore.DocumentSnapshot;
66

77
const testIdFieldName = 'documentId';

integration_test/functions/src/v1/testLab-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fetch from 'node-fetch';
21
import * as admin from 'firebase-admin';
2+
import fetch from 'node-fetch';
33

44
interface AndroidDevice {
55
androidModelId: string;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { REGION } from '../region';
21
import { setGlobalOptions } from 'firebase-functions/v2';
2+
import { REGION } from '../region';
33
setGlobalOptions({ region: REGION });
44

55
export * from './https-tests';

scripts/bin-test/test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as path from 'path';
21
import * as subprocess from 'child_process';
2+
import * as path from 'path';
33
import { promisify } from 'util';
44

5+
import { expect } from 'chai';
6+
import * as yaml from 'js-yaml';
57
import fetch from 'node-fetch';
68
import * as portfinder from 'portfinder';
7-
import * as yaml from 'js-yaml';
89
import * as semver from 'semver';
9-
import { expect } from 'chai';
1010

1111
const TIMEOUT_XL = 20_000;
1212
const TIMEOUT_L = 10_000;
@@ -43,11 +43,11 @@ const BASE_STACK = {
4343
specVersion: 'v1alpha1',
4444
};
4545

46-
type Testcase = {
46+
interface Testcase {
4747
name: string;
4848
modulePath: string;
4949
expected: Record<string, any>;
50-
};
50+
}
5151

5252
async function retryUntil(
5353
fn: () => Promise<boolean>,
@@ -66,7 +66,9 @@ async function retryUntil(
6666
});
6767
const retry = (async () => {
6868
while (true) {
69-
if (await fn()) break;
69+
if (await fn()) {
70+
break;
71+
}
7072
await sleep();
7173
}
7274
})();

spec/common/providers/https.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import * as firebase from 'firebase-admin';
33
import * as sinon from 'sinon';
44

55
import { apps as appsNamespace } from '../../../src/apps';
6-
import {
7-
checkAppCheckContext,
8-
checkAuthContext,
9-
runHandler,
10-
RunHandlerResult,
11-
} from '../../helper';
6+
import * as debug from '../../../src/common/debug';
7+
import * as https from '../../../src/common/providers/https';
8+
import * as mocks from '../../fixtures/credential/key.json';
129
import {
1310
expectedResponseHeaders,
1411
generateAppCheckToken,
@@ -19,9 +16,12 @@ import {
1916
mockFetchPublicKeys,
2017
mockRequest,
2118
} from '../../fixtures/mockrequest';
22-
import * as debug from '../../../src/common/debug';
23-
import * as https from '../../../src/common/providers/https';
24-
import * as mocks from '../../fixtures/credential/key.json';
19+
import {
20+
checkAppCheckContext,
21+
checkAuthContext,
22+
runHandler,
23+
RunHandlerResult,
24+
} from '../../helper';
2525

2626
/**
2727
* A CallTest is a specification for a test of a callable function that

spec/common/providers/identity.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
import { expect } from 'chai';
2324
import * as express from 'express';
2425
import * as jwt from 'jsonwebtoken';
2526
import * as sinon from 'sinon';
2627
import * as identity from '../../../src/common/providers/identity';
27-
import { expect } from 'chai';
2828

2929
const PROJECT = 'my-project';
3030
const EVENT = 'EVENT_TYPE';
@@ -308,8 +308,8 @@ describe('identity', () => {
308308
kid: '123456',
309309
},
310310
{
311-
'123456': '7890',
312-
'2468': '1357',
311+
123456: '7890',
312+
2468: '1357',
313313
}
314314
)
315315
).to.eq('7890');
@@ -438,7 +438,7 @@ describe('identity', () => {
438438
const decoded = {
439439
aud: VALID_URL,
440440
iss: `${identity.JWT_ISSUER}${PROJECT}`,
441-
sub: sub,
441+
sub,
442442
event_type: EVENT,
443443
} as identity.DecodedPayload;
444444

@@ -515,8 +515,8 @@ describe('identity', () => {
515515
let jwtVerifyStub: sinon.SinonStub;
516516
const keysCache = {
517517
publicKeys: {
518-
'123456': '7890',
519-
'2468': '1357',
518+
123456: '7890',
519+
2468: '1357',
520520
},
521521
publicKeysExpireAt: time + identity.INVALID_TOKEN_BUFFER + 10000,
522522
};

spec/common/providers/tasks.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
import { expect } from 'chai';
2424
import * as firebase from 'firebase-admin';
2525

26-
import { checkAuthContext, runHandler } from '../../helper';
27-
import {
28-
generateIdToken,
29-
generateUnsignedIdToken,
30-
mockRequest,
31-
} from '../../fixtures/mockrequest';
26+
import { apps as appsNamespace } from '../../../src/apps';
27+
import * as https from '../../../src/common/providers/https';
3228
import {
3329
onDispatchHandler,
34-
TaskContext,
3530
Request,
31+
TaskContext,
3632
} from '../../../src/common/providers/tasks';
37-
import { apps as appsNamespace } from '../../../src/apps';
3833
import * as mocks from '../../fixtures/credential/key.json';
39-
import * as https from '../../../src/common/providers/https';
34+
import {
35+
generateIdToken,
36+
generateUnsignedIdToken,
37+
mockRequest,
38+
} from '../../fixtures/mockrequest';
39+
import { checkAuthContext, runHandler } from '../../helper';
4040

4141
/** Represents a test case for a Task Queue Function */
4242
interface TaskTest {

0 commit comments

Comments
 (0)