HewlettPackard / oneview-puppet

This project is no longer being developed and has limited support. In the near future this repository will be fully deprecated. Please consider using other OneView projects, such as Terraform and Ansible Collection
https://forge.puppet.com/hewlettpackard/oneview
Apache License 2.0
8 stars 17 forks source link

Unit tests should not require auth files/environment variables from the user. #103

Closed fgbulsoni closed 7 years ago

fgbulsoni commented 7 years ago

Scenario/Intent

Run rake test or other rake/rspec commands to run unit tests without depending on actions from the user.

Steps to Reproduce

Run rake test without having setup an auth file or environment variables.

Expected Result

Should be fine as we're only running unit tests and don't really require external information.

Actual Result

Error, since the credentials could not be set.

fgbulsoni commented 7 years ago

Opened this issue for image streamer, but that was actually OK. When running rake test it was failing because I did not have an image streamer auth file setup. Still, made me wonder about our unit specs and using fixtures. We should not require the user to have the paths set for those, as those could be made to use config files from within fixtures. Modifying this issue and changing it to a future improvement.

marikrg commented 7 years ago

For the Image Streamer, we could just add these lines in the spec_helper:

  if config.filter_manager.inclusions.rules[:unit]
    ENV['IMAGE_STREAMER_AUTH_FILE'] = 'spec/support/fixtures/unit/provider/login_image_streamer.json'
  end

Then, anyone will be able to run the Image Streamer specs with no auth files/environment variables set.

OneView specs need a more robust solution, since it has hardware variants.

What do you think about that?

fgbulsoni commented 7 years ago

Then, anyone will be able to run the Image Streamer specs with no auth files/environment variables set.

I think that sounds pretty good. The solution looks simple enough and we avoid setting variables on travis and facing weird errors where everything should be mocked. Overall I'd give it a go. :+1:

OneView specs need a more robust solution, since it has hardware variants.

As for this, we can likely improve it later once we have #55 fixed and every test is calling its specific provider, then we should be good to also use this solution for ov.

Cheers :octocat: