mirror of
https://github.com/cheat/cheat.git
synced 2025-12-28 09:52:06 +01:00
Re-wrote from scratch in Golang
- Re-implemented the project in Golang, and deprecated Python entirely - Implemented several new, long-requested features - Refactored cheatsheets into a separate repository
This commit is contained in:
34
internal/sheets/sort_test.go
Normal file
34
internal/sheets/sort_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package sheets
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cheat/cheat/internal/sheet"
|
||||
)
|
||||
|
||||
// TestSort asserts that Sort properly sorts sheets
|
||||
func TestSort(t *testing.T) {
|
||||
|
||||
// mock a map of cheatsheets
|
||||
sheets := map[string]sheet.Sheet{
|
||||
"foo": sheet.Sheet{Title: "foo"},
|
||||
"bar": sheet.Sheet{Title: "bar"},
|
||||
"baz": sheet.Sheet{Title: "baz"},
|
||||
}
|
||||
|
||||
// sort the sheets
|
||||
sorted := Sort(sheets)
|
||||
|
||||
// assert that the sheets sorted properly
|
||||
want := []string{"bar", "baz", "foo"}
|
||||
|
||||
for i, got := range sorted {
|
||||
if got.Title != want[i] {
|
||||
t.Errorf(
|
||||
"sort returned incorrect value: want: %s, got: %s",
|
||||
want[i],
|
||||
got.Title,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user