firebase-admin-go
firebase-admin-go copied to clipboard
FR(rtdb): Support for the emulator on http/localhost
Step 3
I'd like to do some integration testing on my local machine for the Realtime Database that's as close to the real thing as possible. I'm trying to use the emulator for this purpose.
Which would probably work, except that NewClient() in db.go enforces https and the url suffix ".firebaseio.com".
Steps to reproduce:
calling DatabaseWithURL() with http://localhost:9000 produces an error.
Relevant Code:
The validation step causing me trouble is here:
func NewClient(ctx context.Context, c *internal.DatabaseConfig) (*Client, error) {
p, err := url.ParseRequestURI(c.URL)
if err != nil {
return nil, err
} else if p.Scheme != "https" {
return nil, fmt.Errorf("invalid database URL: %q; want scheme: %q", c.URL, "https")
} else if !strings.HasSuffix(p.Host, ".firebaseio.com") {
return nil, fmt.Errorf("invalid database URL: %q; want host: %q", c.URL, "firebaseio.com")
}
Let me know if there's any other way to connect to the emulator that I missed!
...and also here:
return &Client{
hc: hc,
url: fmt.Sprintf("https://%s", p.Host),
authOverride: string(ao),
}, nil
The Go SDK doesn't support the emulator at the moment. That needs more work (just fixing URL validation is not enough). We already did this in Python: https://github.com/firebase/firebase-admin-python/pull/313. Similar changes are required here.
Any update on this feature? We're unable to create offline development environments without this or integration tests.
This is now internally tracked as b/136271028 and we'll see if we can get it prioritized. In the meantime, we welcome any Pull Requests on this.
Any update on this?
It's been a whole year since the post about it being tracked as b/136271028, is there any update on this feature?
+1
+1
It looks like @kenshin54 made a PR, can this be merged? Would be really nice to be able to use the database emulator!
It looks like @kenshin54 made a PR, can this be merged? Would be really nice to be able to use the database emulator!
Agreed!
Referenced PR from @kenshin54 was here: https://github.com/firebase/firebase-admin-go/pull/471, but seems to have closed after a period of inactivity.
This feature would help our team quite a bit.
With inspiration from @kenshin54 I've taken another look at this here: https://github.com/firebase/firebase-admin-go/pull/517
Fixed in #517