-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Given the version 0.1.0-x
, ParseRange
returns the following error:
Could not get version from string: "<"
Replacing the x with another character fixes the problem (e.g. 0.1.0-y
).
This appears to be related to x
being used to denote wildcards as implemented in #27:
Line 330 in 4487282
if strings.Contains(ap, "x") { |
This can be reproduced with the following test:
func TestExpandWildcardVersion(t *testing.T) {
tests := []struct {
i [][]string
o [][]string
}{
{[][]string{{"foox"}}, nil},
// FAILING TEST
{[][]string{{"0.1.0-x"}}, [][]string{{"0.1.0-x"}}},
{[][]string{{">=1.2.x"}}, [][]string{{">=1.2.0"}}},
{[][]string{{"<=1.2.x"}}, [][]string{{"<1.3.0"}}},
{[][]string{{">1.2.x"}}, [][]string{{">=1.3.0"}}},
{[][]string{{"<1.2.x"}}, [][]string{{"<1.2.0"}}},
{[][]string{{"!=1.2.x"}}, [][]string{{"<1.2.0", ">=1.3.0"}}},
{[][]string{{">=1.x"}}, [][]string{{">=1.0.0"}}},
{[][]string{{"<=1.x"}}, [][]string{{"<2.0.0"}}},
{[][]string{{">1.x"}}, [][]string{{">=2.0.0"}}},
{[][]string{{"<1.x"}}, [][]string{{"<1.0.0"}}},
{[][]string{{"!=1.x"}}, [][]string{{"<1.0.0", ">=2.0.0"}}},
{[][]string{{"1.2.x"}}, [][]string{{">=1.2.0", "<1.3.0"}}},
{[][]string{{"1.x"}}, [][]string{{">=1.0.0", "<2.0.0"}}},
}
for _, tc := range tests {
o, _ := expandWildcardVersion(tc.i)
if !reflect.DeepEqual(tc.o, o) {
t.Errorf("Invalid for case %q: Expected %q, got: %q", tc.i, tc.o, o)
}
}
}
Result of this test is: Invalid for case [["0.1.0-x"]]: Expected [["0.1.0-x"]], got: [[">=0.1.0-x" "<"]]
At the very least, it would be helpful to call out this corner case in the docs if fixing this would be challenging due to breaking changes.
Metadata
Metadata
Assignees
Labels
No labels