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

Add tests for config file loader util #1059

Merged
merged 5 commits into from
Apr 1, 2019
Merged

Conversation

JakeDawkins
Copy link
Contributor

@JakeDawkins JakeDawkins commented Feb 27, 2019

Goals

  • Test the loadConfig functionality
  • Document/reorganize the logic
  • Bugfixes where discovered by tests

What I did

  • Fixed bug where a user specifies loading of a config with a flag, but if that file isn't found, it loads an apollo.config.js.
    • Ex: apollo client:check --config=config/apollo.js would also load ./apollo.config.js if it couldn't find the specified config. I think if a user is manually specifying a config, it should only load what they specified and throw an error if not found.
    • This was preventing testing errors, since leaving off a config would just load this repo's config (which wouldn't work)
  • Removed the getSearchPlaces function. It was extraneous, and misleading. While search places is the term that dotenv uses, it is less descriptive than defaultFileNames, since that what the search places are–filenames.
  • Added try/catch around the cosmiconfig's loader, since it can throw on malformed files with an unhelpful error.
  • Handled case where .env is not a File, but a folder or something else. Resolves apollo service:push fails because it makes assumptions about the environment #1132
  • Split up project type and service name setting, since those being intertwined added unnecessary complexity
  • commented :allthethings:

TODO:

  • Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.

@JakeDawkins JakeDawkins force-pushed the jake/test-loadConfig branch 3 times, most recently from 877e953 to 50cc697 Compare March 26, 2019 18:13
@JakeDawkins JakeDawkins changed the title [WIP] Add tests for config file loader util Add tests for config file loader util Mar 26, 2019
Copy link
Member

@trevor-scheer trevor-scheer left a comment

Choose a reason for hiding this comment

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

Ship it!

@JakeDawkins JakeDawkins merged commit df158e0 into master Apr 1, 2019
@JakeDawkins JakeDawkins deleted the jake/test-loadConfig branch April 1, 2019 13:51
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.

apollo service:push fails because it makes assumptions about the environment
2 participants