Make it possible to override GK's in unit tests
Summary: Previously it was not possible to run unit tests to test logic that requires GK's to be enabled. This fixes that Reviewed By: passy Differential Revision: D19158368 fbshipit-source-id: b89691bdd2f975a3b4be343bd966ed77b2ad3763
This commit is contained in:
committed by
Facebook Github Bot
parent
4e76256d6d
commit
f4fdeef692
@@ -29,4 +29,22 @@ export default class GK {
|
||||
static serializeGKs() {
|
||||
return '';
|
||||
}
|
||||
|
||||
static async withWhitelistedGK(
|
||||
id: GKID,
|
||||
callback: () => Promise<void> | void,
|
||||
) {
|
||||
whitelistedGKs.push(id);
|
||||
try {
|
||||
const p = callback();
|
||||
if (p) {
|
||||
await p;
|
||||
}
|
||||
} finally {
|
||||
const idx = whitelistedGKs.indexOf(id);
|
||||
if (idx !== -1) {
|
||||
whitelistedGKs.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user