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

Refactor constraints #156

Merged
merged 7 commits into from
May 21, 2024
Merged

Conversation

nanobowers
Copy link
Collaborator

@nanobowers nanobowers commented May 12, 2024

  • Refactor constraints (depends/conflicts/either) into separate classes (DependConstraint, ConflictConstraint, EitherConstraint) with an abstract Constraint class.
  • Add validate method which points to new MinMaxConstraint, plus tests.
    • tbh i'm not too sure about the validate name, the name feels a little unclear about its purpose to me.

@miq-bot add-label refactoring
@miq-bot add-reviewer @Fryguy

@nanobowers nanobowers marked this pull request as draft May 12, 2024 00:58
@nanobowers
Copy link
Collaborator Author

Realized I did not update the documentation, but would like to get feedback on this so moving to draft

@Fryguy
Copy link
Member

Fryguy commented May 13, 2024

tbh i'm not too sure about the validate name, the name feels a little unclear about its purpose to me.

This was also my only concern here. It also takes away from what might be other use cases for validation. For example, we might want to allow similar things to what activerecord validation provides, such as :format or :comparison. That is I could see something like:

opt :max_volume, :type => :integer
opt :start_volume, :type => :integer
validates :start_volume, comparison: { less_than_or_equal_to: :max_volume }

So I think the way forward is give a more clear name for the minmax, but that will likely hold up the refactoring. I'd be ok with a separate PR with just the refactorting, since that's much clearer and I'm basically ready to merge now, and then the mixmax bit can be a smaller PR. I'm still not sure of a realistic use case is for mix max, which makes it a little harder for me to understand.

@nanobowers
Copy link
Collaborator Author

Reverted this to a plain old refactoring of the depend/conflict/either constraints. Can tackle min/max validation in another PR.

@nanobowers nanobowers marked this pull request as ready for review May 16, 2024 11:28
@Fryguy
Copy link
Member

Fryguy commented May 16, 2024

I'm surprised that no specs failed with the changes in wording. Are these tested?

@nanobowers
Copy link
Collaborator Author

I'm surprised that no specs failed with the changes in wording. Are these tested?

No, apparently not. The difference in the algorithm for determining success/failure of the Constraints would make it impractical to match the old failure messages.

Should I put together some tests for the failure messages before closing out this PR?

@Fryguy
Copy link
Member

Fryguy commented May 17, 2024

Should I put together some tests for the failure messages before closing out this PR?

Yes, please - even a few basic tests would be sufficient.

@nanobowers nanobowers merged commit 4667258 into ManageIQ:master May 21, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants