firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

Try to extract context.params from triggered data #114

Closed rhodgkins closed 2 years ago

rhodgkins commented 3 years ago

Description

When running the function, the wrapper tries to extract the EventContext params from the triggered data based on the wildcard path.

E.g. A wildcard path of users/{userId} run against with users/FOO would result in params: { userId: 'FOO' }.

Provided params to the wrapped function are preferred over the extracted ones - I've only done this to prevent breaking usage for anyone whose not matching the values in the path up to the provided params.

Also added tests (and updated the auth and authType tests as they were just being run with junk data).

Code sample

See the tests:

Firebase RTDB - https://github.com/bookcreator/firebase-functions-test/blob/params/spec/main.spec.ts#L150-L165 Firestore - https://github.com/bookcreator/firebase-functions-test/blob/params/spec/main.spec.ts#L167-L185

rhodgkins commented 2 years ago

Can anyone review and, if happy, merge this in please?

rhodgkins commented 2 years ago

Bump @inlined & @taeold

rhodgkins commented 2 years ago

@inlined done and rebased from master and also ran format:fix as I think it was missed from #123