api: test job sort

This commit is contained in:
Ryan Uber 2015-09-17 13:15:45 -07:00
parent 61b8249d08
commit c1aa896918
1 changed files with 19 additions and 0 deletions

View File

@ -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)
}
}