summaryrefslogtreecommitdiff
path: root/internal/task/sort_test.go
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 20:43:12 +0300
committerGitHub <noreply@github.com>2025-06-20 20:43:12 +0300
commitc0dd74fb9b434a17332be11ad867839832d10b63 (patch)
tree781f26f009ba5205c0ddb3ac3c31be3ebd5a95ea /internal/task/sort_test.go
parent438272b134ba537f68884c25f2a015a5218503dd (diff)
parent363caa6301d67c97b29e83e168ed9c83f571355c (diff)
Merge pull request #31 from snonux/codex/sort-tasks-by-due-date,-priority,-tag,-and-id
Implement task sorting by due date and priority
Diffstat (limited to 'internal/task/sort_test.go')
-rw-r--r--internal/task/sort_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/task/sort_test.go b/internal/task/sort_test.go
new file mode 100644
index 0000000..4b034c9
--- /dev/null
+++ b/internal/task/sort_test.go
@@ -0,0 +1,28 @@
+package task
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestSortTasks(t *testing.T) {
+ tasks := []Task{
+ {ID: 2, Due: "20240102T000000Z", Priority: "M", Tags: []string{"b", "a"}},
+ {ID: 1, Due: "20240101T000000Z", Priority: "H", Tags: []string{"a"}},
+ {ID: 3, Due: "", Priority: "", Tags: []string{"c"}},
+ {ID: 4, Due: "20240101T000000Z", Priority: "L", Tags: []string{"a"}},
+ {ID: 5, Due: "20240101T000000Z", Priority: "H", Tags: []string{"b"}},
+ {ID: 6, Due: "20240101T000000Z", Priority: "H", Tags: []string{"b"}},
+ }
+
+ SortTasks(tasks)
+
+ var ids []int
+ for _, tsk := range tasks {
+ ids = append(ids, tsk.ID)
+ }
+ want := []int{1, 5, 6, 4, 2, 3}
+ if !reflect.DeepEqual(ids, want) {
+ t.Fatalf("unexpected order: %v", ids)
+ }
+}