Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ type downloadOption struct {
MaxAttempts int
AcceptPreRelease bool
RoundTripper http.RoundTripper
Username string
Password string
Username string
Password string
Magnet bool
Force bool
Mod int
Expand Down
9 changes: 7 additions & 2 deletions pkg/net/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"testing"
"time"

"github.com/linuxsuren/http-downloader/mock/mhttp"
"github.com/linuxsuren/http-downloader/pkg/net"
Expand Down Expand Up @@ -139,6 +140,9 @@ var _ = Describe("http test", func() {
Debug: true,
TargetFilePath: debugFile,
}
defer func() {
_ = os.RemoveAll(debugFile)
}()

request, _ := http.NewRequest(http.MethodGet, "", nil)
response := &http.Response{
Expand All @@ -153,7 +157,7 @@ var _ = Describe("http test", func() {
Expect(err).To(HaveOccurred())

_, err = os.Stat(debugFile)
Expect(err).NotTo(BeNil())
Expect(err).To(BeNil())
})

It("showProgress", func() {
Expand Down Expand Up @@ -251,7 +255,8 @@ func TestDetectSize(t *testing.T) {
roundTripper.EXPECT().
RoundTrip(mockRequest).Return(mockResponse, nil)

total, rangeSupport, err := net.DetectSizeWithRoundTripper(targetURL, os.TempDir(), false, false, false, roundTripper, 0)
fileName := fmt.Sprintf("%s-%d", os.TempDir(), time.Now().Second())
total, rangeSupport, err := net.DetectSizeWithRoundTripper(targetURL, fileName, false, false, false, roundTripper, 0)
assert.Nil(t, err)
assert.Equal(t, int64(102), total)
assert.True(t, rangeSupport)
Expand Down
Loading