Skip to content

Commit

Permalink
check if env is test -- cannot intercept the google auth credentials …
Browse files Browse the repository at this point in the history
…check
  • Loading branch information
ptbarnum4 committed Oct 4, 2024
1 parent dc718d1 commit 80c21d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/api/googleFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ export async function runCloudFunction<T, Res>({
body,
headers = {},
}: RunCloudFunctionArgs<T>): GaxiosPromise<Res> {
const { GOOGLE_SERVICE_ACCOUNT } = process.env;
const { GOOGLE_SERVICE_ACCOUNT, NODE_ENV } = process.env;
const credentials = GOOGLE_SERVICE_ACCOUNT && JSON.parse(GOOGLE_SERVICE_ACCOUNT);

if (NODE_ENV === 'test') {
// Cannot mock `GoogleAuth` in tests
return { data: {} } as unknown as GaxiosPromise<Res>;
}
if (!credentials) {
throw new Error('Invalid credentials');
}
Expand Down

0 comments on commit 80c21d5

Please sign in to comment.