test: add more sorting tests
This commit is contained in:
parent
19bcaca6e6
commit
f81a7c03b9
|
@ -617,7 +617,7 @@ func TestIsCompatible(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSort(t *testing.T) {
|
||||
func TestSort1(t *testing.T) {
|
||||
rawTags := []string{
|
||||
"v1.4.8",
|
||||
"v1.3.9",
|
||||
|
@ -656,6 +656,43 @@ func TestSort(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSort2(t *testing.T) {
|
||||
rawTags := []string{
|
||||
"10.0",
|
||||
"10.6",
|
||||
"10.2",
|
||||
"10.1",
|
||||
"10.5",
|
||||
"5.5",
|
||||
}
|
||||
|
||||
var tags []tagcmp.Tag
|
||||
for _, rawTag := range rawTags {
|
||||
tag, err := tagcmp.Parse(rawTag)
|
||||
if err != nil {
|
||||
t.Errorf("'%s' should have parsed but didn't: %s", tag, err)
|
||||
}
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
sort.Sort(tagcmp.ByTag(tags))
|
||||
|
||||
expected := []string{
|
||||
"5.5",
|
||||
"10.0",
|
||||
"10.1",
|
||||
"10.2",
|
||||
"10.5",
|
||||
"10.6",
|
||||
}
|
||||
|
||||
for idx, tag := range tags {
|
||||
if tag.String() != expected[idx] {
|
||||
t.Errorf("'%s' sorted out of order, saw '%s', expected '%s'", tag, tags, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
for _, tag := range supported {
|
||||
p, err := tagcmp.Parse(tag)
|
||||
|
|
Loading…
Reference in New Issue