16
16
17
17
'use strict' ;
18
18
19
+ import path = require( 'path' ) ;
19
20
import * as _ from 'lodash' ;
20
21
import { expect } from 'chai' ;
21
22
@@ -38,6 +39,8 @@ describe('Firestore', () => {
38
39
+ 'credentials. Must initialize the SDK with a certificate credential or application default '
39
40
+ 'credentials to use Cloud Firestore API.' ;
40
41
42
+ const mockServiceAccount = path . resolve ( __dirname , '../../resources/mock.key.json' ) ;
43
+
41
44
beforeEach ( ( ) => {
42
45
appCredentials = process . env . GOOGLE_APPLICATION_CREDENTIALS ;
43
46
gcloudProject = process . env . GCLOUD_PROJECT ;
@@ -104,6 +107,7 @@ describe('Firestore', () => {
104
107
it ( 'should not throw given application default credentials without project ID' , ( ) => {
105
108
// Project ID not set in the environment.
106
109
delete process . env . GCLOUD_PROJECT ;
110
+ process . env . GOOGLE_APPLICATION_CREDENTIALS = mockServiceAccount ;
107
111
expect ( ( ) => {
108
112
return new FirestoreService ( defaultCredentialApp ) ;
109
113
} ) . not . to . throw ( ) ;
@@ -147,6 +151,7 @@ describe('Firestore', () => {
147
151
148
152
it ( 'should return a string when project ID is present in environment' , ( ) => {
149
153
process . env . GCLOUD_PROJECT = 'env-project-id' ;
154
+ process . env . GOOGLE_APPLICATION_CREDENTIALS = mockServiceAccount ;
150
155
expect ( ( new FirestoreService ( defaultCredentialApp ) . client as any ) . projectId ) . to . equal ( 'env-project-id' ) ;
151
156
} ) ;
152
157
} ) ;
0 commit comments