diff options
Diffstat (limited to 'internal/askcli/command_list_test.go')
| -rw-r--r-- | internal/askcli/command_list_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/askcli/command_list_test.go b/internal/askcli/command_list_test.go index e6bce83..903f397 100644 --- a/internal/askcli/command_list_test.go +++ b/internal/askcli/command_list_test.go @@ -68,6 +68,48 @@ func TestHandleList_EmptyList(t *testing.T) { } } +func TestHandleAll_Success(t *testing.T) { + jsonData := `[{"uuid":"uuid-1","description":"Done task","status":"completed","priority":"M","tags":[],"urgency":0.0,"depends":[]}]` + d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + for _, arg := range args { + if arg == "export" { + io.WriteString(stdout, jsonData) + return 0, nil + } + } + return 0, nil + }}) + var stdout, stderr bytes.Buffer + code, _ := d.Dispatch(context.Background(), []string{"all"}, nil, &stdout, &stderr) + if code != 0 { + t.Fatalf("all code = %d, want 0", code) + } + if !strings.Contains(stdout.String(), "uuid-1") { + t.Fatalf("output missing uuid-1: %s", stdout.String()) + } +} + +func TestHandleReady_Success(t *testing.T) { + jsonData := `[{"uuid":"uuid-ready","description":"Ready task","status":"pending","priority":"H","tags":["READY"],"urgency":20.0,"depends":[]}]` + d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + for _, arg := range args { + if arg == "export" { + io.WriteString(stdout, jsonData) + return 0, nil + } + } + return 0, nil + }}) + var stdout, stderr bytes.Buffer + code, _ := d.Dispatch(context.Background(), []string{"ready"}, nil, &stdout, &stderr) + if code != 0 { + t.Fatalf("ready code = %d, want 0", code) + } + if !strings.Contains(stdout.String(), "uuid-ready") { + t.Fatalf("output missing uuid-ready: %s", stdout.String()) + } +} + func TestHandleList_PassesFilters(t *testing.T) { var capturedArgs []string d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { |
