Skip to content

Commit 09c47af

Browse files
authored
Fixing some Firestore test warnings, caused by failure to find ADC (#162)
1 parent e981e15 commit 09c47af

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/unit/firestore/firestore.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
'use strict';
1818

19+
import path = require('path');
1920
import * as _ from 'lodash';
2021
import {expect} from 'chai';
2122

@@ -38,6 +39,8 @@ describe('Firestore', () => {
3839
+ 'credentials. Must initialize the SDK with a certificate credential or application default '
3940
+ 'credentials to use Cloud Firestore API.';
4041

42+
const mockServiceAccount = path.resolve(__dirname, '../../resources/mock.key.json');
43+
4144
beforeEach(() => {
4245
appCredentials = process.env.GOOGLE_APPLICATION_CREDENTIALS;
4346
gcloudProject = process.env.GCLOUD_PROJECT;
@@ -104,6 +107,7 @@ describe('Firestore', () => {
104107
it('should not throw given application default credentials without project ID', () => {
105108
// Project ID not set in the environment.
106109
delete process.env.GCLOUD_PROJECT;
110+
process.env.GOOGLE_APPLICATION_CREDENTIALS = mockServiceAccount;
107111
expect(() => {
108112
return new FirestoreService(defaultCredentialApp);
109113
}).not.to.throw();
@@ -147,6 +151,7 @@ describe('Firestore', () => {
147151

148152
it('should return a string when project ID is present in environment', () => {
149153
process.env.GCLOUD_PROJECT = 'env-project-id';
154+
process.env.GOOGLE_APPLICATION_CREDENTIALS = mockServiceAccount;
150155
expect((new FirestoreService(defaultCredentialApp).client as any).projectId).to.equal('env-project-id');
151156
});
152157
});

0 commit comments

Comments
 (0)