|
|
|
|
@ -38,7 +38,7 @@ func TestDownloadClientVerifyChecksum(t *testing.T) {
|
|
|
|
|
Checksum: checksum,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d := NewDownloadClient(config, new(packer.NoopProgressBar))
|
|
|
|
|
d := NewDownloadClient(config, new(packer.NoopUi))
|
|
|
|
|
result, err := d.VerifyChecksum(tf.Name())
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Verify err: %s", err)
|
|
|
|
|
@ -61,7 +61,7 @@ func TestDownloadClient_basic(t *testing.T) {
|
|
|
|
|
Url: ts.URL + "/basic.txt",
|
|
|
|
|
TargetPath: tf.Name(),
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}, new(packer.NoopProgressBar))
|
|
|
|
|
}, new(packer.NoopUi))
|
|
|
|
|
|
|
|
|
|
path, err := client.Get()
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -97,7 +97,7 @@ func TestDownloadClient_checksumBad(t *testing.T) {
|
|
|
|
|
Hash: HashForType("md5"),
|
|
|
|
|
Checksum: checksum,
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}, new(packer.NoopProgressBar))
|
|
|
|
|
}, new(packer.NoopUi))
|
|
|
|
|
|
|
|
|
|
if _, err := client.Get(); err == nil {
|
|
|
|
|
t.Fatal("should error")
|
|
|
|
|
@ -123,7 +123,7 @@ func TestDownloadClient_checksumGood(t *testing.T) {
|
|
|
|
|
Hash: HashForType("md5"),
|
|
|
|
|
Checksum: checksum,
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}, new(packer.NoopProgressBar))
|
|
|
|
|
}, new(packer.NoopUi))
|
|
|
|
|
|
|
|
|
|
path, err := client.Get()
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -155,7 +155,7 @@ func TestDownloadClient_checksumNoDownload(t *testing.T) {
|
|
|
|
|
Hash: HashForType("md5"),
|
|
|
|
|
Checksum: checksum,
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}, new(packer.NoopProgressBar))
|
|
|
|
|
}, new(packer.NoopUi))
|
|
|
|
|
path, err := client.Get()
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
@ -185,7 +185,7 @@ func TestDownloadClient_notFound(t *testing.T) {
|
|
|
|
|
client := NewDownloadClient(&DownloadConfig{
|
|
|
|
|
Url: ts.URL + "/not-found.txt",
|
|
|
|
|
TargetPath: tf.Name(),
|
|
|
|
|
}, new(packer.NoopProgressBar))
|
|
|
|
|
}, new(packer.NoopUi))
|
|
|
|
|
|
|
|
|
|
if _, err := client.Get(); err == nil {
|
|
|
|
|
t.Fatal("should error")
|
|
|
|
|
@ -213,7 +213,7 @@ func TestDownloadClient_resume(t *testing.T) {
|
|
|
|
|
Url: ts.URL,
|
|
|
|
|
TargetPath: tf.Name(),
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}, new(packer.NoopProgressBar))
|
|
|
|
|
}, new(packer.NoopUi))
|
|
|
|
|
|
|
|
|
|
path, err := client.Get()
|
|
|
|
|
if err != nil {
|
|
|
|
|
@ -275,7 +275,7 @@ func TestDownloadClient_usesDefaultUserAgent(t *testing.T) {
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopProgressBar))
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopUi))
|
|
|
|
|
_, err = client.Get()
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
@ -308,7 +308,7 @@ func TestDownloadClient_setsUserAgent(t *testing.T) {
|
|
|
|
|
CopyFile: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopProgressBar))
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopUi))
|
|
|
|
|
_, err = client.Get()
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
@ -407,7 +407,7 @@ func TestDownloadFileUrl(t *testing.T) {
|
|
|
|
|
CopyFile: false,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopProgressBar))
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopUi))
|
|
|
|
|
|
|
|
|
|
// Verify that we fail to match the checksum
|
|
|
|
|
_, err = client.Get()
|
|
|
|
|
@ -438,7 +438,7 @@ func SimulateFileUriDownload(t *testing.T, uri string) (string, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// go go go
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopProgressBar))
|
|
|
|
|
client := NewDownloadClient(config, new(packer.NoopUi))
|
|
|
|
|
path, err := client.Get()
|
|
|
|
|
|
|
|
|
|
// ignore any non-important checksum errors if it's not a unc path
|
|
|
|
|
|