Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove functions.config.singleton #74

Merged
merged 1 commit into from
Oct 6, 2020
Merged

Conversation

saygun
Copy link
Contributor

@saygun saygun commented Sep 14, 2020

Description

functions.config() parses ENV variable(s) only once and saves the value into a variable for later usage. Thus setting a new value to process.env.CLOUD_RUNTIME_CONFIG is not causing getting a recent value.

Motivation
Calling the mockConfig function multiple times with different configuration values makes writing unit tests easier and gives flexibility to the developer. What do you think?

P.S This topic has been already mentioned in #68.

Code Sample

// spec/unit/auth-on-create.spec.ts
import test from 'firebase-functions-test';
const app = test();

describe('[Unit] Auth.onCreate()', () => {
  afterEach(() => {
    app.cleanup();
  });
  
  it('does something with config().foo', () => {
    app.mockConfig({ foo: 'bar' });
    ...
  });

  it('does something with config().baz', () => {
    app.mockConfig({ baz: 'qux' });
    ...
  });
});

@AlphonseSantoro
Copy link

This is exactly what I'm looking for. Is there anything blocking this?

@saygun
Copy link
Contributor Author

saygun commented Oct 1, 2020

Still waiting for the response from core members.

@saygun
Copy link
Contributor Author

saygun commented Oct 5, 2020

@laurenzlong @bkendall @ShoeBoom guys any comment on this?

@ShoeBoom
Copy link
Contributor

ShoeBoom commented Oct 5, 2020

I'm not actually a part of the firebase team btw. The code itself lgtm

Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I'll release a new version of firebase-functions-test sometime later this week so y'all can use this. Thanks for the contribution!

@joehan joehan merged commit 2574781 into firebase:master Oct 6, 2020
@cwygoda
Copy link

cwygoda commented Oct 24, 2020

Good evening y'all! Any chance to get this released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants