k1LoW / awspec

RSpec tests for your AWS resources.
MIT License
1.17k stars 193 forks source link

Add support for a custom aws endpoint #580

Closed sverch closed 1 year ago

sverch commented 1 year ago

There may be other use cases, but my main use case is to run this against the standalone moto server: http://docs.getmoto.org/en/latest/docs/server_mode.html

This would allow awspec to be used as part of a full test loop for aws automation without the need to configure an aws account.

sverch commented 1 year ago

Thanks for the great project @k1LoW. The nice code architecture also made it easier to find where to add this option.

Let me know if you want me to add a test case or an example. I have a full working example with passing tests that I could add to this PR.

sverch commented 1 year ago

Sorry about the failure. I didn't think to try regenerating the docs since I wasn't changing any resources. It should be fixed now.

$ bundle exec bin/toolbox docgen >| doc/resource_types.md

This now works and generates the same docs as before. The issue was that passing nil as the endpoint would cause the sdk to throw an error rather than treating it as unset.

sverch commented 1 year ago

Fixed the linter error. $ bundle exec rubocop lib/awspec/helper/finder.rb passes now so I think it should work on a PR check (but bundle exec rake spec:rubocop returns unrelated errors).

sverch commented 1 year ago

Updated with your comments! Also reran these, so hopefully the tests won't fail again.

$ diff <(bundle exec bin/toolbox docgen 2>/dev/null) doc/resource_types.md
(no difference)
$ bundle exec rubocop lib/awspec/helper/finder.rb 2>&1 | grep offenses
1 file inspected, no offenses detected
sverch commented 1 year ago

@k1LoW No problem! This project has been helpful, and I'm glad for the chance to contribute back!