forked from toolshed/tagcmp
@ -617,7 +617,7 @@ func TestIsCompatible(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSort1(t *testing.T) {
|
||||
func TestSortAsc1(t *testing.T) {
|
||||
rawTags := []string{
|
||||
"v1.4.8",
|
||||
"v1.3.9",
|
||||
@ -637,7 +637,7 @@ func TestSort1(t *testing.T) {
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
sort.Sort(tagcmp.ByTag(tags))
|
||||
sort.Sort(tagcmp.ByTagAsc(tags))
|
||||
|
||||
expected := []string{
|
||||
"v0.0.1",
|
||||
@ -656,7 +656,7 @@ func TestSort1(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSort2(t *testing.T) {
|
||||
func TestSortAsc2(t *testing.T) {
|
||||
rawTags := []string{
|
||||
"10.0",
|
||||
"10.6",
|
||||
@ -675,7 +675,7 @@ func TestSort2(t *testing.T) {
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
sort.Sort(tagcmp.ByTag(tags))
|
||||
sort.Sort(tagcmp.ByTagAsc(tags))
|
||||
|
||||
expected := []string{
|
||||
"5.5",
|
||||
@ -693,6 +693,43 @@ func TestSort2(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortDesc(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.ByTagDesc(tags))
|
||||
|
||||
expected := []string{
|
||||
"10.6",
|
||||
"10.5",
|
||||
"10.2",
|
||||
"10.1",
|
||||
"10.0",
|
||||
"5.5",
|
||||
}
|
||||
|
||||
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)
|
||||
@ -730,7 +767,7 @@ func TestGiteaFilterCompatible(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(tagcmp.ByTag(filtered))
|
||||
sort.Sort(tagcmp.ByTagAsc(filtered))
|
||||
|
||||
for idx, tag := range filtered {
|
||||
if tag.String() != expected[idx] {
|
||||
|
Reference in New Issue
Block a user