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

Refactored if statement tests to table tests to increase readability … #22564

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

griffinbird
Copy link

@griffinbird griffinbird commented Mar 9, 2024

…and maintainability.

  • [ X] The purpose of this PR is explained in this or a referenced issue.
  • [ X] The PR does not update generated files.
  • [ X] Tests are included and/or updated for code changes.
  • Updates to module CHANGELOG.md are included.
  • [ X] MIT license headers are included in each file.

@RickWinter
Copy link
Member

@lirenhe can you analyze and determine if you want to take this change. Currently it is failing various pipelines so it needs work before it can be accepted

}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

I personally find this refactoring a bit less clear than the ifs. Having to understand the usage of t.Run with the delegate seems a bit more complicated than understanding a list of if conditions.

But I would see value if these ifs are unbounded/can keep growing, so it would reduce the volume of code required. But the reality is that these properties will not really change frequently so the chances of a developer having to keep adding checks here is very low to offset the increase in reading complexity.

Finally, the same pattern (ifs) are used throughout the other files. If we want to think a common pattern, I guess we would need to refactor all the other files too?

@lirenhe
Copy link

lirenhe commented Apr 28, 2024

@lirenhe can you analyze and determine if you want to take this change. Currently it is failing various pipelines so it needs work before it can be accepted

@RickWinter, could you help to provide more context about its impact? Is there any pipelines in mgmt. SDK that also need this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants