Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
strategy:
matrix:
node-version:
- 14.x
- 16.x
- 20.x
- 22.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -36,16 +36,16 @@ jobs:
strategy:
matrix:
node-version:
- 14.x
- 16.x
- 20.x
- 22.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix(firestore): use hostname from env variable (#184)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this more descriptive and around the user journey like "Correct the hostname for Firestore events in the emulator"

40 changes: 23 additions & 17 deletions spec/providers/firestore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('providers/firestore', () => {
test = fft();
fakeHttpResponse = {
statusCode: 200,
on: ((event, cb) => cb())
on: (event, cb) => cb(),
};
fakeHttpRequestMethod = sinon.fake((config, cb) => {
cb(fakeHttpResponse);
Expand Down Expand Up @@ -91,26 +91,32 @@ describe('providers/firestore', () => {
it('should use host name from FIRESTORE_EMULATOR_HOST env in clearFirestoreData', async () => {
process.env.FIRESTORE_EMULATOR_HOST = 'not-local-host:8080';

await test.firestore.clearFirestoreData({projectId: 'not-a-project'});

expect(fakeHttpRequestMethod.calledOnceWith({
hostname: 'not-local-host',
method: 'DELETE',
path: '/emulator/v1/projects/not-a-project/databases/(default)/documents',
port: '8080'
})).to.be.true;
await test.firestore.clearFirestoreData({ projectId: 'not-a-project' });

expect(
fakeHttpRequestMethod.calledOnceWith({
hostname: 'not-local-host',
method: 'DELETE',
path:
'/emulator/v1/projects/not-a-project/databases/(default)/documents',
port: '8080',
})
).to.be.true;
});

it('should use host name from FIREBASE_FIRESTORE_EMULATOR_ADDRESS env in clearFirestoreData', async () => {
process.env.FIREBASE_FIRESTORE_EMULATOR_ADDRESS = 'custom-host:9090';

await test.firestore.clearFirestoreData({projectId: 'not-a-project'});

expect(fakeHttpRequestMethod.calledOnceWith({
hostname: 'custom-host',
method: 'DELETE',
path: '/emulator/v1/projects/not-a-project/databases/(default)/documents',
port: '9090'
})).to.be.true;
await test.firestore.clearFirestoreData({ projectId: 'not-a-project' });

expect(
fakeHttpRequestMethod.calledOnceWith({
hostname: 'custom-host',
method: 'DELETE',
path:
'/emulator/v1/projects/not-a-project/databases/(default)/documents',
port: '9090',
})
).to.be.true;
});
});