mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 01:50:30 +00:00
feat: improve http download strategy to prevent speed drops near completion (#969)
This commit is contained in:
4 files changed
+263
-134
No files matched your search
@@ -246,6 +246,33 @@ func TestFetcher_ConfigUseServerCtime(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetcher_Stats(t *testing.T) {
|
||||
listener := test.StartTestFileServer()
|
||||
defer listener.Close()
|
||||
fetcher := doDownloadReady(buildConfigFetcher(config{
|
||||
Connections: 16,
|
||||
}), listener, 0, t)
|
||||
err := fetcher.Start()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = fetcher.Wait()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stats := fetcher.Stats().(*http.Stats)
|
||||
if len(stats.Connections) != 16 {
|
||||
t.Errorf("Stats() got = %v, want %v", len(stats.Connections), 16)
|
||||
}
|
||||
totalDownloaded := int64(0)
|
||||
for _, conn := range stats.Connections {
|
||||
totalDownloaded += conn.Downloaded
|
||||
}
|
||||
if totalDownloaded != test.BuildSize {
|
||||
t.Errorf("Stats() got = %v, want %v", totalDownloaded, test.BuildSize)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetcherManager_ParseName(t *testing.T) {
|
||||
type args struct {
|
||||
u string
|
||||
|
||||
Reference in new issue
Block a user