Merge pull request #7410 from tiendc/unit_test_releaseutil

Add unit test for Reverse() in pkg/releaseutil/sorter.go
pull/7779/head
Martin Hickey 5 years ago committed by GitHub
commit 93137abbb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,3 +79,30 @@ func TestSortByRevision(t *testing.T) {
return vi < vj
})
}
func TestReverseSortByName(t *testing.T) {
Reverse(releases, SortByName)
check(t, "ByName", func(i, j int) bool {
ni := releases[i].Name
nj := releases[j].Name
return ni > nj
})
}
func TestReverseSortByDate(t *testing.T) {
Reverse(releases, SortByDate)
check(t, "ByDate", func(i, j int) bool {
ti := releases[i].Info.LastDeployed.Second()
tj := releases[j].Info.LastDeployed.Second()
return ti > tj
})
}
func TestReverseSortByRevision(t *testing.T) {
Reverse(releases, SortByRevision)
check(t, "ByRevision", func(i, j int) bool {
vi := releases[i].Version
vj := releases[j].Version
return vi > vj
})
}

Loading…
Cancel
Save