MCPcopy
hub / github.com/SurgeDM/Surge / TestUpdate_DownloadStartedKeepsResuming

Function TestUpdate_DownloadStartedKeepsResuming

internal/tui/update_test.go:80–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func 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
118func TestUpdate_DownloadStartedPropagatesRateLimit(t *testing.T) {
119 dm := NewDownloadModel("id-1", "http://example.com/file", "file", 0)

Callers

nothing calls this directly

Calls 4

UpdateMethod · 0.95
NewProgressStateFunction · 0.92
NewDownloadModelFunction · 0.85
NewDownloadListFunction · 0.85

Tested by

no test coverage detected