summaryrefslogtreecommitdiff
path: root/internal/task/stats_test.go
blob: fddbd694a37bd65fd5fa0a08ea9c99298fbdcb1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package task

import (
	"testing"
	"time"
)

func TestStats(t *testing.T) {
	now := time.Now()
	tasks := []Task{
		{Description: "t1"},
		{Description: "t2", Start: "20240101T000000Z"},
		{Description: "t3", Due: now.Add(-time.Hour).Format("20060102T150405Z")},
		{Description: "t4", Start: "20240101T000000Z", Due: now.Add(-time.Hour).Format("20060102T150405Z")},
	}

	if TotalTasks(tasks) != 4 {
		t.Errorf("total tasks wrong: %d", TotalTasks(tasks))
	}

	if InProgressTasks(tasks) != 2 {
		t.Errorf("in progress wrong: %d", InProgressTasks(tasks))
	}

	if DueTasks(tasks, now) != 2 {
		t.Errorf("due tasks wrong: %d", DueTasks(tasks, now))
	}
}