-
Notifications
You must be signed in to change notification settings - Fork 152
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
strict version checking feature #243
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ func TestParseConstraint(t *testing.T) { | |
}{ | ||
{">= 1.2", constraintGreaterThanEqual, "1.2.0", false}, | ||
{"1.0", constraintTildeOrEqual, "1.0.0", false}, | ||
{"==1.0", constraintEqual, "1.0.0", false}, | ||
{"==1", constraintEqual, "1.0.0", false}, | ||
{"foo", nil, "", true}, | ||
{"<= 1.2", constraintLessThanEqual, "1.2.0", false}, | ||
{"=< 1.2", constraintLessThanEqual, "1.2.0", false}, | ||
|
@@ -138,6 +140,23 @@ func TestConstraintCheck(t *testing.T) { | |
{"2", "2.1.1", true}, | ||
{"2.1", "2.1.1", true}, | ||
{"2.1", "2.2.1", false}, | ||
{"==2", "1", false}, | ||
{"==2", "3.4.5", false}, | ||
{"==2", "2.0.0", false}, | ||
{"==2", "2.0.0+alpha", false}, | ||
{"==2", "2.0.0-alpha", false}, | ||
{"==2", "2.0.1", false}, | ||
{"==2.1", "2.1.0", false}, | ||
{"==2.1.x", "2.1.0", false}, | ||
{"==2.1.x", "2.1.1", false}, | ||
Comment on lines
+143
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't have a version that's "2". So, a constraint of Since other comparisons allow shortened versions with assumptions on missing parts this looks to be confusing to user input that's run through here. That, I think, means more support requests. node-semver does When I look at What do you think of the node-semver model? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with your point, since there was no double equal operator I didn't thinked too much about it, maybe I am wrong, here what I think should be some constraints examples that follows the node-semver model:
I'm pretty much ok with the node-semver model, and this example as well, if we can be sure to find a specific version or subset of versions it would be perfect 👍 |
||
{"==2.1", "2.1.1", false}, | ||
{"==2.1", "2.2.1", false}, | ||
{"==2.1.1", "2.1.1", true}, | ||
{"==2.1.1", "2.2.1", false}, | ||
{"==2.1.1+alpha", "2.1.1+alpha.1", false}, | ||
{"==2.1.1+alpha.1", "2.1.1+alpha.1", true}, | ||
{"==2.1.1-alpha", "2.1.1-alpha.1", false}, | ||
{"==2.1.1-alpha.1", "2.1.1-alpha.1", true}, | ||
{"~1.2.3", "1.2.4", true}, | ||
{"~1.2.3", "1.3.4", false}, | ||
{"~1.2", "1.2.4", true}, | ||
|
@@ -290,7 +309,10 @@ func TestConstraintsCheck(t *testing.T) { | |
{"= 2.0", "1.2.3", false}, | ||
{"= 2.0", "2.0.0", true}, | ||
{"4.1", "4.1.0", true}, | ||
{"4.1", "4.1.3+alpha", true}, | ||
{"4.1.x", "4.1.3", true}, | ||
{"4.1.x", "4.1.3+alpha", true}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the issue, it's also the case without dirty |
||
{"4.1.3", "4.1.3+alpha", true}, | ||
{"1.x", "1.4", true}, | ||
{"!=4.1", "4.1.0", false}, | ||
{"!=4.1-alpha", "4.1.0-alpha", false}, | ||
|
@@ -474,14 +496,27 @@ func TestConstraintsValidate(t *testing.T) { | |
{"= 2.0", "1.2.3", false}, | ||
{"= 2.0", "2.0.0", true}, | ||
{"4.1", "4.1.0", true}, | ||
{"4.1", "4.1.3+alpha", true}, | ||
{"4.1.x", "4.1.3", true}, | ||
{"4.1.x", "4.1.3+alpha", true}, | ||
{"4.1.3", "4.1.3+alpha", true}, | ||
{"1.x", "1.4", true}, | ||
{"!=4.1", "4.1.0", false}, | ||
{"!=4.1", "5.1.0", true}, | ||
{"!=4.x", "5.1.0", true}, | ||
{"!=4.x", "4.1.0", false}, | ||
{"!=4.1.x", "4.2.0", true}, | ||
{"!=4.2.x", "4.2.3", false}, | ||
{"==4.1", "4.1.0", false}, | ||
{"==4.1", "5.1.0", false}, | ||
{"==4.x", "5.1.0", false}, | ||
{"==4.x", "4.1.0", false}, | ||
{"==4.1.x", "4.2.0", false}, | ||
{"==4.1.0", "4.1.0", true}, | ||
{"==4.1.0+alpha", "4.1.0+alpha", true}, | ||
{"==4.1.0+alpha", "4.1.0+alpha-1", false}, | ||
{"==4.1.0-alpha", "4.1.0-alpha-1", false}, | ||
{"==4.2.x", "4.2.3", false}, | ||
{">1.1", "4.1.0", true}, | ||
{">1.1", "1.1.0", false}, | ||
{"<1.1", "0.1.0", true}, | ||
|
@@ -600,6 +635,15 @@ func TestConstraintsValidate(t *testing.T) { | |
{"= 2.0", "1.2.3", "1.2.3 is less than 2.0"}, | ||
{"!=4.1", "4.1.0", "4.1.0 is equal to 4.1"}, | ||
{"!=4.x", "4.1.0", "4.1.0 is equal to 4.x"}, | ||
{"==4.x", "5.1.0", "5.1.0 is not equal to 4.x"}, | ||
{"==4.x", "4.1.0", "4.1.0 is not equal to 4.x"}, | ||
{"==4.1.x", "4.1.0", "4.1.0 is not equal to 4.1.x"}, | ||
{"==4.1.x", "4.2.0", "4.2.0 is not equal to 4.1.x"}, | ||
{"==4.1.2", "4.1.3", "4.1.3 is not equal to 4.1.2"}, | ||
{"==4.1.2-beta", "4.1.2-beta.1", "4.1.2-beta.1 is not equal to 4.1.2-beta"}, | ||
{"==4.1.2+beta", "4.1.2+beta.1", "4.1.2+beta.1 is not equal to 4.1.2+beta"}, | ||
{"==4.0.1", "4.0.1-beta.1", "4.0.1-beta.1 is a prerelease version and the constraint is only looking for release versions"}, | ||
{"==4.2", "4.1.0", "4.1.0 is not equal to 4.2"}, | ||
{"!=4.2.x", "4.2.3", "4.2.3 is equal to 4.2.x"}, | ||
{">1.1", "1.1.0", "1.1.0 is less than or equal to 1.1"}, | ||
{"<1.1", "1.1.0", "1.1.0 is greater than or equal to 1.1"}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described here, the issue lied in here, we are not able to differentiate a version with metadatas and a version without metadatas with the actual constraints comparisons possibilities