mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-29 21:08:17 +00:00
Fix up tests
This commit is contained in:
@@ -3,18 +3,19 @@ package http
|
||||
import (
|
||||
"compress/bzip2"
|
||||
"compress/gzip"
|
||||
"github.com/smira/go-xz"
|
||||
"fmt"
|
||||
"github.com/mxk/go-flowrate/flowrate"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/smira/go-ftp-protocol/protocol"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mxk/go-flowrate/flowrate"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/smira/go-ftp-protocol/protocol"
|
||||
"github.com/smira/go-xz"
|
||||
)
|
||||
|
||||
// HTTPError is download error connected to HTTP code
|
||||
@@ -59,7 +60,13 @@ type downloadTask struct {
|
||||
// NewDownloader creates new instance of Downloader which specified number
|
||||
// of threads and download limit in bytes/sec
|
||||
func NewDownloader(threads int, downLimit int64, progress aptly.Progress) aptly.Downloader {
|
||||
transport := *http.DefaultTransport.(*http.Transport)
|
||||
transport := http.Transport{}
|
||||
transport.Proxy = http.DefaultTransport.(*http.Transport).Proxy
|
||||
transport.DialContext = http.DefaultTransport.(*http.Transport).DialContext
|
||||
transport.MaxIdleConns = http.DefaultTransport.(*http.Transport).MaxIdleConns
|
||||
transport.IdleConnTimeout = http.DefaultTransport.(*http.Transport).IdleConnTimeout
|
||||
transport.TLSHandshakeTimeout = http.DefaultTransport.(*http.Transport).TLSHandshakeTimeout
|
||||
transport.ExpectContinueTimeout = http.DefaultTransport.(*http.Transport).ExpectContinueTimeout
|
||||
transport.DisableCompression = true
|
||||
transport.RegisterProtocol("ftp", &protocol.FTPRoundTripper{})
|
||||
|
||||
@@ -135,7 +142,7 @@ func (downloader *downloaderImpl) Download(url string, destination string, resul
|
||||
// DownloadWithChecksum starts new download task with checksum verification
|
||||
func (downloader *downloaderImpl) DownloadWithChecksum(url string, destination string, result chan<- error,
|
||||
expected utils.ChecksumInfo, ignoreMismatch bool, maxTries int) {
|
||||
downloader.queue <- &downloadTask{url: url, destination: destination, result: result, expected: expected, ignoreMismatch: ignoreMismatch, triesLeft: maxTries}
|
||||
downloader.queue <- &downloadTask{url: url, destination: destination, result: result, expected: expected, ignoreMismatch: ignoreMismatch, triesLeft: maxTries}
|
||||
}
|
||||
|
||||
// handleTask processes single download task
|
||||
@@ -155,7 +162,6 @@ func (downloader *downloaderImpl) handleTask(task *downloadTask) {
|
||||
req.URL.RawQuery = ""
|
||||
}
|
||||
|
||||
|
||||
var temppath string
|
||||
for task.triesLeft > 0 {
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ package http
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/console"
|
||||
"github.com/smira/aptly/utils"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@@ -14,6 +11,10 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/console"
|
||||
"github.com/smira/aptly/utils"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
@@ -247,7 +248,7 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) {
|
||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
||||
d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404})
|
||||
d.ExpectResponse("http://example.com/file.xz", xzData)
|
||||
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false)
|
||||
r, file, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false, 1)
|
||||
c.Assert(err, IsNil)
|
||||
defer file.Close()
|
||||
io.ReadFull(r, buf)
|
||||
|
||||
Reference in New Issue
Block a user