TestSort asserts that Sort properly sorts sheets
(t *testing.T)
| 8 | |
| 9 | // TestSort asserts that Sort properly sorts sheets |
| 10 | func TestSort(t *testing.T) { |
| 11 | |
| 12 | // mock a map of cheatsheets |
| 13 | sheets := map[string]sheet.Sheet{ |
| 14 | "foo": sheet.Sheet{Title: "foo"}, |
| 15 | "bar": sheet.Sheet{Title: "bar"}, |
| 16 | "baz": sheet.Sheet{Title: "baz"}, |
| 17 | } |
| 18 | |
| 19 | // sort the sheets |
| 20 | sorted := Sort(sheets) |
| 21 | |
| 22 | // assert that the sheets sorted properly |
| 23 | want := []string{"bar", "baz", "foo"} |
| 24 | |
| 25 | for i, got := range sorted { |
| 26 | if got.Title != want[i] { |
| 27 | t.Errorf( |
| 28 | "sort returned incorrect value: want: %s, got: %s", |
| 29 | want[i], |
| 30 | got.Title, |
| 31 | ) |
| 32 | } |
| 33 | } |
| 34 | } |