@@ -58,14 +58,14 @@ func (s *PowerClientTestSuite) TearDownTest(c *check.C) {
5858}
5959
6060func (s * PowerClientTestSuite ) TestDownloadPiece (c * check.C ) {
61- // dstIP != pc.node && CheckConnect Fail
61+ // dstIP != pc.node && pc.pieceTask.Path != pc.cfg.URL && CheckConnect Fail
6262 s .powerClient .pieceTask .PeerIP = "127.0.0.2"
6363 content , err := s .powerClient .downloadPiece ()
6464 c .Check (content , check .IsNil )
6565 c .Check (err , check .NotNil )
6666 s .reset ()
6767
68- // dstIP != pc.node && CheckConnect Success && Download Fail
68+ // dstIP != pc.node && pc.pieceTask.Path != pc.cfg.URL && CheckConnect Success && Download Fail
6969 s .powerClient .node = "127.0.0.2"
7070 downloadMock = func () (* http.Response , error ) {
7171 return nil , fmt .Errorf ("error" )
@@ -75,6 +75,17 @@ func (s *PowerClientTestSuite) TestDownloadPiece(c *check.C) {
7575 c .Check (err , check .DeepEquals , fmt .Errorf ("error" ))
7676 s .reset ()
7777
78+ // dstIP != pc.node && pc.pieceTask.Path == pc.cfg.URL && Download Fail
79+ s .powerClient .node = "127.0.0.3"
80+ s .powerClient .pieceTask .Path = s .powerClient .cfg .URL
81+ downloadMock = func () (* http.Response , error ) {
82+ return nil , fmt .Errorf ("error" )
83+ }
84+ content , err = s .powerClient .downloadPiece ()
85+ c .Check (content , check .IsNil )
86+ c .Check (err , check .DeepEquals , fmt .Errorf ("error" ))
87+ s .reset ()
88+
7889 // dstIP == pc.node && Download Success && StatusCode == 416
7990 body1 := ioutil .NopCloser (bytes .NewReader ([]byte ("RangeNotSatisfiable" )))
8091 defer func () {
@@ -162,7 +173,7 @@ func (s *PowerClientTestSuite) TestReadBody(c *check.C) {
162173
163174func (s * PowerClientTestSuite ) reset () {
164175 s .powerClient = & PowerClient {
165- cfg : & config.Config {RV : config.RuntimeVariable {Cid : "" }},
176+ cfg : & config.Config {RV : config.RuntimeVariable {Cid : "" }, URL : "http://127.0.0.1/" },
166177 node : "127.0.0.1" ,
167178 rateLimiter : ratelimiter .NewRateLimiter (int64 (5 ), 2 ),
168179 downloadAPI : NewMockDownloadAPI (),
0 commit comments