Skip to content

Commit f7d511e

Browse files
committed
Add top-level bucket field to Mock Storage CloudEvents (#145)
Storage CloudEvents contain a "bucket" field. The mock data should return this "bucket" field to accurately reflect live data. [More info here](https://github.com/firebase/firebase-functions/blob/27a49837ea7b74d9d2926e74c387f45704d57889/src/v2/providers/storage.ts#L185)
1 parent 49b5380 commit f7d511e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

spec/v2.spec.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,30 +134,42 @@ describe('v2', () => {
134134
describe('storage', () => {
135135
describe('storage.onObjectArchived()', () => {
136136
it('should update CloudEvent appropriately', () => {
137-
const cloudFn = storage.onObjectArchived('bucket', handler);
137+
const bucket = 'bucket';
138+
const cloudFn = storage.onObjectArchived(bucket, handler);
138139
const cloudFnWrap = wrapV2(cloudFn);
139-
expect(cloudFnWrap().cloudEvent).to.include({});
140+
expect(cloudFnWrap().cloudEvent).to.include({
141+
bucket,
142+
});
140143
});
141144
});
142145
describe('storage.onObjectDeleted()', () => {
143146
it('should update CloudEvent appropriately', () => {
144-
const cloudFn = storage.onObjectDeleted('bucket', handler);
147+
const bucket = 'bucket';
148+
const cloudFn = storage.onObjectDeleted(bucket, handler);
145149
const cloudFnWrap = wrapV2(cloudFn);
146-
expect(cloudFnWrap().cloudEvent).to.include({});
150+
expect(cloudFnWrap().cloudEvent).to.include({
151+
bucket,
152+
});
147153
});
148154
});
149155
describe('storage.onObjectFinalized()', () => {
150156
it('should update CloudEvent appropriately', () => {
151-
const cloudFn = storage.onObjectFinalized('bucket', handler);
157+
const bucket = 'bucket';
158+
const cloudFn = storage.onObjectFinalized(bucket, handler);
152159
const cloudFnWrap = wrapV2(cloudFn);
153-
expect(cloudFnWrap().cloudEvent).to.include({});
160+
expect(cloudFnWrap().cloudEvent).to.include({
161+
bucket,
162+
});
154163
});
155164
});
156165
describe('storage.onObjectMetadataUpdated()', () => {
157166
it('should update CloudEvent appropriately', () => {
158-
const cloudFn = storage.onObjectMetadataUpdated('bucket', handler);
167+
const bucket = 'bucket';
168+
const cloudFn = storage.onObjectMetadataUpdated(bucket, handler);
159169
const cloudFnWrap = wrapV2(cloudFn);
160-
expect(cloudFnWrap().cloudEvent).to.include({});
170+
expect(cloudFnWrap().cloudEvent).to.include({
171+
bucket,
172+
});
161173
});
162174
});
163175
});

src/cloudevent/partials/storage/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const storageV1: MockCloudEventPartials<StorageEvent> = {
1313
const subject = `objects/${FILENAME}`;
1414

1515
return {
16+
bucket,
1617
source,
1718
subject,
1819
data: getStorageObjectData(bucket, FILENAME, 1),

0 commit comments

Comments
 (0)