This repository was archived by the owner on Dec 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
2727 "path/filepath"
2828 "strings"
2929 "testing"
30+ "time"
3031
3132 "github.com/dragonflyoss/Dragonfly/dfget/config"
3233 . "github.com/dragonflyoss/Dragonfly/dfget/core/helper"
@@ -139,6 +140,24 @@ func (s *CoreTestSuite) TestCheckConnectSupernode(c *check.C) {
139140 c .Assert (ip , check .Equals , "" )
140141}
141142
143+ func (s * CoreTestSuite ) TestCalculateTimeout (c * check.C ) {
144+ cfg := s .createConfig (& bytes.Buffer {})
145+
146+ timeout := calculateTimeout (nil )
147+ c .Assert (timeout , check .Equals , config .DefaultDownloadTimeout )
148+
149+ timeout = calculateTimeout (cfg )
150+ c .Assert (timeout , check .Equals , config .DefaultDownloadTimeout )
151+
152+ cfg .RV .FileLength = 1000
153+ timeout = calculateTimeout (cfg )
154+ c .Assert (timeout , check .Equals , 10 * time .Second )
155+
156+ cfg .Timeout = time .Minute
157+ timeout = calculateTimeout (cfg )
158+ c .Assert (timeout , check .Equals , time .Minute )
159+ }
160+
142161// ----------------------------------------------------------------------------
143162// helper functions
144163
You can’t perform that action at this time.
0 commit comments