-
Notifications
You must be signed in to change notification settings - Fork 59
Implement firebase-functions-test wrapV2 #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
26bef11
Implement firebase-functions-test wrapV2
TheIronDev 620efec
Minor updates (per pr comments.)
TheIronDev 25f1686
Implement createMockCloudEvent for v2 wrap
TheIronDev da6d7f6
Fix how V2 CloudEventSource gets populated
TheIronDev 5ead878
Fix CloudEvent.subject and CloudEvent.source
TheIronDev 173244e
Bumped semver to 1.0.0
TheIronDev 7a6a36b
Added support for eventarc custom events
TheIronDev 7a43876
Fix follow ups from PR feedback
TheIronDev c6bc418
Handle V2 function behavior within the main.ts#wrap call
TheIronDev 2614eb5
Decouple wrapV1 logic from main.ts#wrap
TheIronDev c535541
Add in Partial Typing instead of CloudEventOverride
TheIronDev 4cb0038
Fix issue with broken typing (CloudBaseEvent isn't exported)
TheIronDev 5c873ea
Follow up items from PR feedback
TheIronDev 6865768
Create and Implement MockCloudEvent
TheIronDev eac837e
Refactor V2 wrap function
TheIronDev 7c40120
Implemented StorageObjectData and improved typing
TheIronDev 14805af
Introduce DeepPartial
TheIronDev 8d232d9
Wire up deep merge
TheIronDev dfcdebe
Implement data generation for Alerts
TheIronDev 5726338
Fix Types for AppDistributionEvent, BillingEvent, and CrashlyticsEvent
TheIronDev 503aa65
Split the cloudevent partial definitions to different files
TheIronDev afbeac8
Implement mock MessagePublishedData for pubsub
TheIronDev 510a880
Update EventArc sample CloudEvent
TheIronDev c259fdf
Updated Unit tests for PubSub data.message generation
TheIronDev c6ad354
Update returned type for `Alert.OnAlertPublished` partial
TheIronDev 614139b
Remove `param` from default CloudEvent generation
TheIronDev b2eeddd
Fix all the imports (from /lib/v2/providers -> /v2)
TheIronDev 3b92144
Fix redundant typing
TheIronDev 87cd8cb
DRY cleanup
TheIronDev c7e7845
Patch Minor lint issues
TheIronDev a530aac
Removed hardcoded json from pubsub partial generator
TheIronDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2018 Firebase | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
import {expect} from 'chai'; | ||
|
||
import {alerts, storage} from 'firebase-functions/v2'; | ||
import {generateMockCloudEvent} from '../../src/cloudevent/generate'; | ||
|
||
describe('generate (CloudEvent)', () => { | ||
describe('#generateMockCloudEvent', () => { | ||
describe('alerts.billing.onPlanAutomatedUpdatePublished()', () => { | ||
it('should create CloudEvent with appropriate fields', () => { | ||
const cloudFn = alerts.billing.onPlanAutomatedUpdatePublished(() => { | ||
}); | ||
const cloudEvent = | ||
generateMockCloudEvent(cloudFn); | ||
|
||
expect(cloudEvent.type).equal( | ||
'google.firebase.firebasealerts.alerts.v1.published'); | ||
expect(cloudEvent.source).equal( | ||
'//firebasealerts.googleapis.com/projects/42'); | ||
expect(cloudEvent.subject).equal(undefined); | ||
}); | ||
}); | ||
describe('storage.onObjectArchived', () => { | ||
it('should create CloudEvent with appropriate fields', () => { | ||
const bucketName = 'bucket_name'; | ||
const cloudFn = storage.onObjectArchived(bucketName, () => { | ||
}); | ||
const cloudEvent = | ||
generateMockCloudEvent(cloudFn); | ||
|
||
expect(cloudEvent.type).equal( | ||
'google.cloud.storage.object.v1.archived'); | ||
expect(cloudEvent.source).equal( | ||
`//storage.googleapis.com/projects/_/buckets/${bucketName}`); | ||
expect(cloudEvent.subject).equal('objects/file_name'); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and another test for when bucketName is not specified |
||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and eventually tests on
data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack (will follow up!)