(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func TestUpdate_DownloadStartedKeepsResuming(t *testing.T) { |
| 81 | dm := NewDownloadModel("id-1", "http://example.com/file", "file", 0) |
| 82 | dm.paused = true |
| 83 | dm.pausing = true |
| 84 | dm.resuming = true |
| 85 | m := RootModel{ |
| 86 | downloads: []*DownloadModel{dm}, |
| 87 | list: NewDownloadList(80, 20), |
| 88 | logViewport: viewport.New(viewport.WithWidth(40), viewport.WithHeight(5)), |
| 89 | } |
| 90 | |
| 91 | msg := events.DownloadStartedMsg{ |
| 92 | DownloadID: "id-1", |
| 93 | URL: "http://example.com/file", |
| 94 | Filename: "file", |
| 95 | Total: 100, |
| 96 | DestPath: "/tmp/file", |
| 97 | State: types.NewProgressState("id-1", 100), |
| 98 | } |
| 99 | |
| 100 | updated, _ := m.Update(msg) |
| 101 | m2 := updated.(RootModel) |
| 102 | var d *DownloadModel |
| 103 | for _, dl := range m2.downloads { |
| 104 | if dl.ID == "id-1" { |
| 105 | d = dl |
| 106 | break |
| 107 | } |
| 108 | } |
| 109 | if d == nil { |
| 110 | t.Fatal("Expected download id-1 to exist") |
| 111 | return |
| 112 | } |
| 113 | if d.paused || d.pausing || !d.resuming { |
| 114 | t.Fatalf("Expected paused/pausing cleared and resuming preserved on DownloadStartedMsg, got paused=%v pausing=%v resuming=%v", d.paused, d.pausing, d.resuming) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func TestUpdate_DownloadStartedPropagatesRateLimit(t *testing.T) { |
| 119 | dm := NewDownloadModel("id-1", "http://example.com/file", "file", 0) |
nothing calls this directly
no test coverage detected