(t *testing.T)
| 688 | } |
| 689 | |
| 690 | func TestStartDownload_UsesModelEnqueueContext(t *testing.T) { |
| 691 | svc := core.NewLocalDownloadServiceWithInput(nil, nil) |
| 692 | t.Cleanup(func() { |
| 693 | _ = svc.Shutdown() |
| 694 | }) |
| 695 | |
| 696 | ctx, cancel := context.WithCancel(context.Background()) |
| 697 | cancel() |
| 698 | |
| 699 | orchestrator := processing.NewLifecycleManager( |
| 700 | func(string, string, string, []string, map[string]string, bool, int64, bool) (string, error) { |
| 701 | t.Fatal("enqueue dispatch should not run after context cancellation") |
| 702 | return "", nil |
| 703 | }, |
| 704 | nil, |
| 705 | ) |
| 706 | |
| 707 | m := RootModel{ |
| 708 | Settings: config.DefaultSettings(), |
| 709 | Service: svc, |
| 710 | Orchestrator: orchestrator, |
| 711 | enqueueCtx: ctx, |
| 712 | cancelEnqueue: func() {}, |
| 713 | list: NewDownloadList(80, 20), |
| 714 | logViewport: viewport.New(viewport.WithWidth(40), viewport.WithHeight(5)), |
| 715 | } |
| 716 | |
| 717 | updated, cmd := m.startDownload("https://example.com/file.bin", nil, nil, t.TempDir(), false, "file.bin", "") |
| 718 | if cmd == nil { |
| 719 | t.Fatal("expected enqueue command") |
| 720 | } |
| 721 | if len(updated.downloads) != 1 { |
| 722 | t.Fatalf("expected optimistic queued download, got %d", len(updated.downloads)) |
| 723 | } |
| 724 | |
| 725 | msg := cmd() |
| 726 | errMsg, ok := msg.(enqueueErrorMsg) |
| 727 | if !ok { |
| 728 | t.Fatalf("msg = %T, want enqueueErrorMsg", msg) |
| 729 | } |
| 730 | if !errors.Is(errMsg.err, context.Canceled) { |
| 731 | t.Fatalf("err = %v, want context canceled", errMsg.err) |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | func TestStartDownload_GuessesFilenameOptimisticallyWhenProvidedOrInferred(t *testing.T) { |
| 736 | svc := core.NewLocalDownloadServiceWithInput(nil, nil) |
nothing calls this directly
no test coverage detected