soumak77 / firebase-mock

Firebase mock library for writing unit tests
https://soumak77.github.io/firebase-mock
349 stars 97 forks source link

Support Cloud Functions v1 #72

Open soumak77 opened 6 years ago

soumak77 commented 6 years ago

Firebase SDK for Cloud Functions version 1 was just released and changes the API for all non-HTTP functions. This library needs to be updated to support the new API, while still providing backwards compatibility for the old API.

a-xin commented 6 years ago

@soumak77 Happy to help with this, have you already started planning or implementing support for v1? Any bigger changes to firebase-mock you'd be expecting? My guess is that mainly implementation and usage of the DeltaSnapshot interface would need to be changed to the new DataSnapshot interface.

I recently switched a project (using auth and triggers, rtdb and triggers, cloud functions, pubsub) to firebase-functions v1 and I was able to migrate the tests and continue using firebase-mock without major incompatibilities.

I'm not sure I completely understand your suggestion for supporting v1 while keeping backwards compatibility:

  1. Do you suggest supporting both v0.9 and v1 in the same code base?
  2. Or would you use the approach the firebase team used, ie. doing a major version update on the master branch that supports v1 only (and keep a separate branch to allow for important fixes to the old API)?

As support for the old API will be dropped completely end of this year, I'd vote for approach 2) to keep the code base as lean as possible, instead of having to support to ways of interacting with it.

soumak77 commented 6 years ago

@a-xin I think both function versions can be supported at once without a new major version. We just need to expose a way to create the input parameters used by the functions, similar to how DeltaDocumentSnapshot was created to use for firestore functions prior to v1.

Feel free to work on a PR to add this support.