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

Bugfix: correctly read node-config environment variables explicitly set to false #245

Merged
merged 8 commits into from
Feb 1, 2024

Conversation

norrisng-bc
Copy link
Contributor

Description

This PR resolves #86.

Environment variables with a value of false are now correctly interpreted as such. Previously, the mere presence of a key would mean that its value would be interpreted as true, even if it is explicitly set to false.

https://apps.nrs.gov.bc.ca/int/jira/browse/SHOWCASE-3115

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

The Jira ticket contains the following suggested implementation:

const foo: boolean = config.has('some.thing') && utils.isTruthy(config.get('some.thing'));

This approach was ultimately not used, as the potential short-circuiting of the boolean (i.e. when the config doesn't contain 'some.thing') would interefere with Jest mocking since isTruthy() won't get called, throwing off the order of the mocks.

Instead, config.get() is used, with the potential exception (raised when 'some.thing' doesn't exist) handled as appropriate.

This implementation is encapsulated in the helper function utils.getConfigBoolean() under /app/src/components/utils.js.

Copy link

Coverage Report

Totals Coverage
Statements: 59.8% ( 2808 / 4696 )
Methods: 50.39% ( 320 / 635 )
Lines: 66.51% ( 1688 / 2538 )
Branches: 52.53% ( 800 / 1523 )

Copy link

codeclimate bot commented Jan 31, 2024

Code Climate has analyzed commit b42f1fa and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 76.1% (50% is the threshold).

This pull request will bring the total coverage in the repository to 66.5% (0.0% change).

View more on Code Climate.

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.

getAppAuthMode does not evaluate configuration values
3 participants