api: test job sort
This commit is contained in:
parent
61b8249d08
commit
c1aa896918
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
@ -303,3 +304,21 @@ func TestJobs_Constrain(t *testing.T) {
|
|||
t.Fatalf("expect: %#v, got: %#v", expect, job.Constraints)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobs_Sort(t *testing.T) {
|
||||
jobs := []*JobListStub{
|
||||
&JobListStub{ID: "job2"},
|
||||
&JobListStub{ID: "job0"},
|
||||
&JobListStub{ID: "job1"},
|
||||
}
|
||||
sort.Sort(JobIDSort(jobs))
|
||||
|
||||
expect := []*JobListStub{
|
||||
&JobListStub{ID: "job0"},
|
||||
&JobListStub{ID: "job1"},
|
||||
&JobListStub{ID: "job2"},
|
||||
}
|
||||
if !reflect.DeepEqual(jobs, expect) {
|
||||
t.Fatalf("\n\n%#v\n\n%#v", jobs, expect)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue