summaryrefslogtreecommitdiff
path: root/internal/askcli/render_task_list_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-18 08:05:32 +0300
committerPaul Buetow <paul@buetow.org>2026-06-18 08:05:32 +0300
commita80ad2b4691d0df63f68c6977ee18444e7bb752f (patch)
tree6edc47fcc3c929856826432cf3df3394a14934e8 /internal/askcli/render_task_list_test.go
parent4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b (diff)
ik0 replace remaining test seams with DI
Diffstat (limited to 'internal/askcli/render_task_list_test.go')
-rw-r--r--internal/askcli/render_task_list_test.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/internal/askcli/render_task_list_test.go b/internal/askcli/render_task_list_test.go
index ff47153..42a5e0d 100644
--- a/internal/askcli/render_task_list_test.go
+++ b/internal/askcli/render_task_list_test.go
@@ -10,10 +10,7 @@ import (
)
func TestRenderTaskList_JSONOutput(t *testing.T) {
- oldLoader := taskListAliasLoader
- defer func() { taskListAliasLoader = oldLoader }()
-
- taskListAliasLoader = func(tasks []TaskExport) (map[string]string, error) {
+ loadAliases := func(tasks []TaskExport) (map[string]string, error) {
return map[string]string{"uuid-json": "sq"}, nil
}
@@ -26,7 +23,7 @@ func TestRenderTaskList_JSONOutput(t *testing.T) {
Urgency: 12.5,
}}
var stdout, stderr bytes.Buffer
- code, err := renderTaskList(tasks, &stdout, &stderr, true)
+ code, err := renderTaskListWithAliasLoader(tasks, &stdout, &stderr, true, loadAliases)
if err != nil {
t.Fatalf("renderTaskList returned error: %v", err)
}
@@ -50,10 +47,7 @@ func TestRenderTaskList_JSONOutput(t *testing.T) {
}
func TestRenderTaskList_TextOutputUsesAliasLoader(t *testing.T) {
- oldLoader := taskListAliasLoader
- defer func() { taskListAliasLoader = oldLoader }()
-
- taskListAliasLoader = func(tasks []TaskExport) (map[string]string, error) {
+ loadAliases := func(tasks []TaskExport) (map[string]string, error) {
if len(tasks) != 1 || tasks[0].UUID != "uuid-text" {
t.Fatalf("unexpected tasks passed to loader: %#v", tasks)
}
@@ -61,7 +55,7 @@ func TestRenderTaskList_TextOutputUsesAliasLoader(t *testing.T) {
}
var stdout, stderr bytes.Buffer
- code, err := renderTaskList([]TaskExport{{UUID: "uuid-text", Description: "Text task", Priority: "L"}}, &stdout, &stderr, false)
+ code, err := renderTaskListWithAliasLoader([]TaskExport{{UUID: "uuid-text", Description: "Text task", Priority: "L"}}, &stdout, &stderr, false, loadAliases)
if err != nil {
t.Fatalf("renderTaskList returned error: %v", err)
}
@@ -78,14 +72,11 @@ func TestRenderTaskList_TextOutputUsesAliasLoader(t *testing.T) {
}
func TestRenderTaskList_AliasLoaderError(t *testing.T) {
- oldLoader := taskListAliasLoader
- defer func() { taskListAliasLoader = oldLoader }()
-
- taskListAliasLoader = func([]TaskExport) (map[string]string, error) {
+ loadAliases := func([]TaskExport) (map[string]string, error) {
return nil, fmt.Errorf("boom")
}
var stdout, stderr bytes.Buffer
- code, err := renderTaskList([]TaskExport{{UUID: "uuid-error"}}, &stdout, &stderr, false)
+ code, err := renderTaskListWithAliasLoader([]TaskExport{{UUID: "uuid-error"}}, &stdout, &stderr, false, loadAliases)
if err != nil {
t.Fatalf("renderTaskList returned error: %v", err)
}