Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <[email protected]>
  • Loading branch information
jim3ma committed Dec 9, 2021
1 parent 541ca02 commit 030a09e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/daemon/peer/piece_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestPieceManager_DownloadSource(t *testing.T) {
checkDigest bool
}{
{
name: "multiple pieces with content length",
name: "multiple pieces with content length, check digest",
pieceSize: 1024,
checkDigest: true,
withContentLength: true,
Expand All @@ -95,7 +95,7 @@ func TestPieceManager_DownloadSource(t *testing.T) {
withContentLength: true,
},
{
name: "multiple pieces without content length",
name: "multiple pieces without content length, check digest",
pieceSize: 1024,
checkDigest: true,
withContentLength: false,
Expand Down Expand Up @@ -131,12 +131,18 @@ func TestPieceManager_DownloadSource(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
/********** prepare test start **********/
mockPeerTask := NewMockTask(ctrl)
var totalPieces int32
mockPeerTask.EXPECT().SetContentLength(gomock.Any()).AnyTimes().DoAndReturn(
func(arg0 int64) error {
return nil
})
mockPeerTask.EXPECT().SetTotalPieces(gomock.Any()).AnyTimes().DoAndReturn(
func(arg0 int32) {
totalPieces = arg0
})
mockPeerTask.EXPECT().GetTotalPieces().AnyTimes().DoAndReturn(
func() int32 {
return totalPieces
})
mockPeerTask.EXPECT().GetPeerID().AnyTimes().DoAndReturn(
func() string {
Expand Down

0 comments on commit 030a09e

Please sign in to comment.