firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.14k stars 247 forks source link

feat(rtdb): add go rtdb emulator support #517

Closed r-LaForge closed 1 year ago

r-LaForge commented 1 year ago

Discussion

This PR hopes to add support for the RTDB Emulator, and is discussed here: https://github.com/firebase/firebase-admin-go/issues/298

There was a previous attempt here: https://github.com/firebase/firebase-admin-go/pull/471

The Python and Node SDK emulation was followed as an example.

Testing

Unit tests have been added to ensure the emulator config (url + namespace) is set correctly. All others still pass. I have also adjusted the integration tests to be able to run against the emulator. Simply run:

# localhost:9000 simply being the default port.
 FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000 FIREBASE_DATABASE_EMULATOR_NAMESPACE=<your-db> go test ./integration/db

Please note the FIREBASE_DATABASE_EMULATOR_NAMESPACE is only used to set the database name during tests.

API Changes

No public API changes.

RELEASE NOTE: The Realtime Database API now supports running against Firebase emulator suite. Enable the emulator mode by setting the FIREBASE_DATABASE_EMULATOR_HOST environment variable to point to the emulator Database endpoint.

Fixes: #298

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

r-LaForge commented 1 year ago

I've signed the CLA check and I'm not sure why google-oss is showing up as a contributor.

image

other PRs appear to have this same issue: https://github.com/firebase/firebase-admin-go/pull/511

r-LaForge commented 1 year ago

Thank you for kicking off CI I fixed the lint issue.

lahirumaramba commented 1 year ago

I've signed the CLA check and I'm not sure why google-oss is showing up as a contributor. image

other PRs appear to have this same issue: #511

@r-LaForge I have seen this happen if we switch the base branch from to dev from the github UI. Did you by any chance based your initial changes on the main branch? If that's the case could you try rebasing to dev locally and push the changes?

r-LaForge commented 1 year ago

@lahirumaramba Thanks for checking this out.

Rebase shows branch is up to date

# dev was synched from upstream beforehand just in case.
$ git rebase dev 
Current branch feature/go-rtdb-emulator is up to date.

Branching directly from dev and creating another PR with the specific file changes results in the same outcome: https://github.com/firebase/firebase-admin-go/pull/519

lahirumaramba commented 1 year ago

Thank you so much @r-LaForge for your contribution! We will include this change in the next release of the Admin Go SDK.