Skip to content

Conversation

@JordonPhillips
Copy link
Member

When we removed the CLI error handling, we missed this case of
using ClientError since it was catching "Exception". This switches
to catching ClientError directly.

In the future, I think this entire command and its tests will need
to be refactored.

cc @kyleknap @jamesls

When we removed the CLI error handling, we missed this case of
using ClientError since it was catching "Exception". This switches
to catching ClientError directly.
@JordonPhillips JordonPhillips added the pr:needs-review This PR needs a review from a Member. label Jun 30, 2016
list.append({'Role': response['Role'], 'RolePolicy': policy})
return list

def _check_if_role_exists(self, role_name, parsed_globals):
Copy link
Member

Choose a reason for hiding this comment

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

Why are we making this public? If it's not intended to be called from other classes I don't think we should be changing internal vs. public for a bug fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue is that the command is exceedingly difficult to test. It needs to have some significant refactoring. At the moment though, we have a broken command.

Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to follow up here. I see the change has been merged and I don't think we need to do anything else here, but I do want to make sure I clarify my thoughts for future changes we may need to make. I realize I wasn't entirely clear on what I meant.

What I was trying to communicate earlier was that we should only make a method public because we want that to be part of the public interface, not because it makes our tests more "correct" because we're not testing internal methods. In general for these types of changes I would prefer to just accept the fact that we're testing internal methods and not make it public. Until such time where we consider rewriting it to be better structured. Consider:

  • It's less code (and less risk) than having to find/replace the method name and ensure we change _foo to foo. For these types of changes I think as minimal a change as possible is ideal.
  • The method really is intended to be internal (i.e if we created another class in this module that was going to use this class, I wouldn't want it calling this internal-but-now-public method).

Yes, avoiding testing internal methods is ideal, but I don't think artificially changing public visibility so we can check the "not-testing-internal-methods" box seems correct.

Hope that helps clarify things going forward.

@jamesls jamesls added incorporating-feedback and removed pr:needs-review This PR needs a review from a Member. labels Jul 1, 2016
@JordonPhillips JordonPhillips added pr:needs-review This PR needs a review from a Member. needs-discussion and removed incorporating-feedback labels Jul 12, 2016
@kyleknap
Copy link
Contributor

🚢 I would rather see this be exposed as a public method. It was bad that an internal method was being tested in the first place.

@JordonPhillips JordonPhillips merged commit b923fbf into aws:develop Jul 18, 2016
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this pull request Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-discussion pr:needs-review This PR needs a review from a Member.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants