From a80ad2b4691d0df63f68c6977ee18444e7bb752f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 18 Jun 2026 08:05:32 +0300 Subject: ik0 replace remaining test seams with DI --- internal/askcli/render_task_list_test.go | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'internal/askcli/render_task_list_test.go') 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) } -- cgit v1.2.3