-
Notifications
You must be signed in to change notification settings - Fork 252
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
Fix a failing test introduced in #28. #35
Conversation
The environment variables in the 'fails if env vars are set' test were not actually being set because they used a nonexistent hash key (which has the effect of unsetting the environment variable).
@haabaato PTAL - this makes the test pass but let me know if there's a better fix. |
- ServiceAccountCredentials, ServiceAccountJwtHeaderCredentials and UserRefreshCredentials initializers now take keyword args via options hash. - In `credentials_loader.rb`, refactored env var checking into private methods - Updated tests & added new tests. - Fixed existing test for #from_well_known_path 'fails if the file is invalid', where `from_env` was called instead of `from_well_known_path`. - Fixed rubocop errors I introduced, but two existing ones remain. - Added entry to changelog. - Fixed rubocop errors from code containing parallel assignments - Updated rubocop_todo.yml to ignore parallel assignments and trailing underscore assignments.
Apologies for the delay as I'm currently attending a conference. 👍 |
this was addressed more properly in #36 so closing this. |
argh, sorry, I read that too fast. |
Is this still necessary ? |
The test still fails for me without this change, so I think it's still needed. |
Can you describe a bit more the environment where this test is failing; at the moment Travis is green ? |
Ok, this is safe to add as it does not break the tests, and IUC, it breaks your other PR. |
Fix a failing test introduced in #28.
That is a good question about why it was failing for me locally but not failing in travis (which it clearly is not). I was using ruby 1.9 but that doesn't seem to be it, I also see the failure with 2.2. @haabaato - any thoughts? FWIW, here is the (edited) log:
|
The test was always passing for me locally, but as I was trying to mention above, it was only passing because |
Ah, thanks - now I understand exactly what is happening. In my case it was picking up ~/.config/gcloud/application_default_credentials.json off the local disk and not throwing the exception. If I remove that file, then the test passes even without this PR. Using fakefs everywhere (which Tim already opened as #40) would prevent that from happening. FWIW, I did try doing that (it's literally a 1-liner, 'require fakefs'), but there were some failures, so I went with a more narrow approach for my new tests. But, it's definitely a good idea. Maybe we can also do ENV.clear to prevent the user's environment from leaking in? |
The environment variables in the 'fails if env vars are set' test
were not actually being set because they used a nonexistent hash key
(which has the effect of unsetting the environment variable).