diff --git a/api/jobs_test.go b/api/jobs_test.go index e42420db2..d421dde67 100644 --- a/api/jobs_test.go +++ b/api/jobs_test.go @@ -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) + } +}