Commit 0182a8a
authored
Implement firebase-functions-test wrapV2 (#131)
* Implement firebase-functions-test wrapV2
* Minor updates (per pr comments.)
This commit makes some minor updates to resolve pr comments.
I still need to go back and clean up the createCloudEvent usecase.
Stay tuned!
* Implement createMockCloudEvent for v2 wrap
This commit implements the createMockCloudEvent.
This simplifies the story of testing the wrapped V2 function.
* Fix how V2 CloudEventSource gets populated
* Fix CloudEvent.subject and CloudEvent.source
* Bumped semver to 1.0.0
* Added support for eventarc custom events
* Fix follow ups from PR feedback
* Handle V2 function behavior within the main.ts#wrap call
* Decouple wrapV1 logic from main.ts#wrap
This cl decouples the implementation logic from wrapping V1 functions
and places it into a separate directory.
I went back and re-exported the same exports from v1 back out to main.ts
to reduce disruption from existing usage.
* Add in Partial Typing instead of CloudEventOverride
* Fix issue with broken typing (CloudBaseEvent isn't exported)
* Follow up items from PR feedback
CloudEvent stuff is being decoupled shortly, stay tuned!™
* Create and Implement MockCloudEvent
This commit introduces MockCloudEvent.
Its very apparent the switch-case shenanigans are too brittle to
handle the growing number of CloudEvents. So Instead, I'm
introducing a wrapper that contains most of the implementation
within `src/mock-cloud-event-partial-definitions.ts`.
The wrapper uses a `match` function to see which implementation of
MockCloudEventPartial to use, and then uses a `generatePartial`
to get the expected Partial<CloudEvent>.
This is not particularly DRY, but it seemed more useful to
keep the building blocks basic rather than being too clever. I'm
happy to be convinced otherwise though.
I'll be breaking / updating other unit tests momentarily.
* Refactor V2 wrap function
This commit refactors the V2 wrap function, removing the need for
the end-user to generate a mock event to pass into the function.
The spec tests are still mostly useless, and we are still missing
data.
I wanted to finish this refactor before implementing the data potion,
otherwise it would be more work to clean up.
* Implemented StorageObjectData and improved typing
* Introduce DeepPartial
Because Partials' don't Partial down recursively.
* Wire up deep merge
* Implement data generation for Alerts
* Fix Types for AppDistributionEvent, BillingEvent, and CrashlyticsEvent
* Split the cloudevent partial definitions to different files
This is a quality-of-life improvement that splits up the giant
`src/mock-cloud-event-partial-definitions.ts` by event type.
`src/mock-cloud-event-partial-definitions.ts` is now just `partials.ts`,
and it returns a list of partials that are all definined in different
files.
Its not the DRYest thing in thr world... but its much more readable.
* Implement mock MessagePublishedData for pubsub
* Update EventArc sample CloudEvent
* Updated Unit tests for PubSub data.message generation
* Update returned type for `Alert.OnAlertPublished` partial
* Remove `param` from default CloudEvent generation
* Fix all the imports (from /lib/v2/providers -> /v2)
* Fix redundant typing
`<FunctionType, EventType>` -> `<EventType>`
* DRY cleanup
* Patch Minor lint issues
* Removed hardcoded json from pubsub partial generator
Removing the hardcoded json from the partial. There needs to be a better pattern.
Stay tuned ™1 parent c1dd82b commit 0182a8a
File tree
30 files changed
+9906
-351
lines changed- spec
- cloudevent
- src
- cloudevent
- partials
- alerts
- eventarc
- pubsub
- storage
30 files changed
+9906
-351
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
229 | 242 | | |
230 | 243 | | |
231 | 244 | | |
| |||
0 commit comments