Skip to content

Commit

Permalink
Merge pull request #36 from Masterminds/fix/34
Browse files Browse the repository at this point in the history
Fixed #34: Simple range syntax requires a space
  • Loading branch information
mattfarina authored Dec 13, 2016
2 parents 434b8de + 4ecd025 commit e4c7885
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func init() {
cvRegex))

constraintRangeRegex = regexp.MustCompile(fmt.Sprintf(
`\s*(%s)\s*-\s*(%s)\s*`,
`\s*(%s)\s+-\s+(%s)\s*`,
cvRegex, cvRegex))
}

Expand Down
13 changes: 7 additions & 6 deletions constraints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ func TestNewConstraint(t *testing.T) {
}{
{">= 1.1", 1, 1, false},
{"2.0", 1, 1, false},
{"v2.3.5-20161202202307-sha.e8fc5e5", 1, 1, false},
{">= bar", 0, 0, true},
{">= 1.2.3, < 2.0", 1, 2, false},
{">= 1.2.3, < 2.0 || => 3.0, < 4", 2, 2, false},

// The 3-4 should be broken into 2 by the range rewriting
{"3-4 || => 3.0, < 4", 2, 2, false},
// The 3 - 4 should be broken into 2 by the range rewriting
{"3 - 4 || => 3.0, < 4", 2, 2, false},
}

for _, tc := range tests {
Expand Down Expand Up @@ -243,9 +244,9 @@ func TestRewriteRange(t *testing.T) {
c string
nc string
}{
{"2-3", ">= 2, <= 3"},
{"2-3, 2-3", ">= 2, <= 3,>= 2, <= 3"},
{"2-3, 4.0.0-5.1", ">= 2, <= 3,>= 4.0.0, <= 5.1"},
{"2 - 3", ">= 2, <= 3"},
{"2 - 3, 2 - 3", ">= 2, <= 3,>= 2, <= 3"},
{"2 - 3, 4.0.0 - 5.1", ">= 2, <= 3,>= 4.0.0, <= 5.1"},
}

for _, tc := range tests {
Expand Down Expand Up @@ -418,7 +419,7 @@ func TestConstraintsValidate(t *testing.T) {
{">=1.1, <2, !=1.2.3", "1.2.3", "1.2.3 is equal to 1.2.3"},
{">=1.1, <2, !=1.2.3 || > 3", "3.0.0", "3.0.0 is greater than or equal to 2"},
{">=1.1, <2, !=1.2.3 || > 3", "1.2.3", "1.2.3 is equal to 1.2.3"},
{"1.1-3", "4.3.2", "4.3.2 is greater than 3"},
{"1.1 - 3", "4.3.2", "4.3.2 is greater than 3"},
{"^1.1", "4.3.2", "4.3.2 does not have same major version as 1.1"},
{"^2.x", "1.1.1", "1.1.1 does not have same major version as 2.x"},
{"^1.x", "2.1.1", "2.1.1 does not have same major version as 1.x"},
Expand Down

0 comments on commit e4c7885

Please sign in to comment.