diff --git a/common/step_download_test.go b/common/step_download_test.go index ce7961c1f..e50483781 100644 --- a/common/step_download_test.go +++ b/common/step_download_test.go @@ -5,7 +5,6 @@ import ( "context" "crypto/sha1" "encoding/hex" - "github.com/hashicorp/packer/packer" "io/ioutil" "log" "net/http" @@ -18,6 +17,7 @@ import ( "github.com/google/go-cmp/cmp" urlhelper "github.com/hashicorp/go-getter/v2/helper/url" "github.com/hashicorp/packer/helper/multistep" + "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer/tmp" ) @@ -74,7 +74,7 @@ func TestStepDownload_Run(t *testing.T) { fields{Url: []string{abs(t, "./test-fixtures/root/another.txt")}}, multistep.ActionContinue, []string{ - toSha1(abs(t, "./test-fixtures/root/another.txt")), + // toSha1(abs(t, "./test-fixtures/root/another.txt")), toSha1(abs(t, "./test-fixtures/root/another.txt")) + ".lock", }, }, @@ -82,7 +82,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Url: []string{abs(t, "./test-fixtures/root//another.txt")}}, multistep.ActionContinue, []string{ - toSha1(abs(t, "./test-fixtures/root//another.txt")), toSha1(abs(t, "./test-fixtures/root//another.txt")) + ".lock", }, }, @@ -90,7 +89,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Url: []string{abs(t, "./test-fixtures/root/another.txt")}, ChecksumType: "none"}, multistep.ActionContinue, []string{ - toSha1(abs(t, "./test-fixtures/root/another.txt")), toSha1(abs(t, "./test-fixtures/root/another.txt")) + ".lock", }, }, @@ -159,7 +157,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Extension: "txt", Url: []string{"./test-fixtures/root/another.txt?checksum=" + cs["/root/another.txt"]}}, multistep.ActionContinue, []string{ - toSha1(cs["/root/another.txt"]) + ".txt", toSha1(cs["/root/another.txt"]) + ".txt.lock", }, }, @@ -167,7 +164,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Extension: "txt", Url: []string{"./test-fixtures/root/another.txt?"}, Checksum: cs["/root/another.txt"]}, multistep.ActionContinue, []string{ - toSha1(cs["/root/another.txt"]) + ".txt", toSha1(cs["/root/another.txt"]) + ".txt.lock", }, }, @@ -175,7 +171,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Extension: "txt", Url: []string{"./test-fixtures/root/another.txt?"}, ChecksumType: "sha1", Checksum: cs["/root/another.txt"]}, multistep.ActionContinue, []string{ - toSha1(cs["/root/another.txt"]) + ".txt", toSha1(cs["/root/another.txt"]) + ".txt.lock", }, }, @@ -183,7 +178,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Extension: "txt", Url: []string{abs(t, "./test-fixtures/root/another.txt") + "?checksum=" + cs["/root/another.txt"]}}, multistep.ActionContinue, []string{ - toSha1(cs["/root/another.txt"]) + ".txt", toSha1(cs["/root/another.txt"]) + ".txt.lock", }, }, @@ -191,7 +185,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Extension: "txt", Url: []string{abs(t, "./test-fixtures/root/another.txt") + "?"}, Checksum: cs["/root/another.txt"]}, multistep.ActionContinue, []string{ - toSha1(cs["/root/another.txt"]) + ".txt", toSha1(cs["/root/another.txt"]) + ".txt.lock", }, }, @@ -199,7 +192,6 @@ func TestStepDownload_Run(t *testing.T) { fields{Extension: "txt", Url: []string{abs(t, "./test-fixtures/root/another.txt") + "?"}, ChecksumType: "sha1", Checksum: cs["/root/another.txt"]}, multistep.ActionContinue, []string{ - toSha1(cs["/root/another.txt"]) + ".txt", toSha1(cs["/root/another.txt"]) + ".txt.lock", }, }, @@ -214,7 +206,6 @@ func TestStepDownload_Run(t *testing.T) { }, multistep.ActionContinue, []string{ - toSha1(cs["/root/basic.txt"]), toSha1(cs["/root/basic.txt"]) + ".lock", }, }, @@ -272,9 +263,8 @@ func TestStepDownload_download(t *testing.T) { if err != nil { t.Fatalf("Bad: non expected error %s", err.Error()) } - if filepath.Ext(path) != "."+step.Extension { - t.Fatalf("bad: path should contain extension %s but it was %s", step.Extension, filepath.Ext(path)) - } + // because of the inplace option; the result file will not be renamed + // sha.ova. os.RemoveAll(step.TargetPath) // Abs path with no extension provided @@ -284,20 +274,18 @@ func TestStepDownload_download(t *testing.T) { if err != nil { t.Fatalf("Bad: non expected error %s", err.Error()) } - if filepath.Ext(path) != ".iso" { - t.Fatalf("bad: path should contain extension %s but it was .iso", step.Extension) - } + // because of the inplace option; the result file will not be renamed + // sha.ova. os.RemoveAll(step.TargetPath) // Path with file step.TargetPath = "./packer/file.iso" - path, err = step.download(context.TODO(), ui, "./test-fixtures/root/basic.txt") + _, err = step.download(context.TODO(), ui, "./test-fixtures/root/basic.txt") if err != nil { t.Fatalf("Bad: non expected error %s", err.Error()) } - if path != "./packer/file.iso" { - t.Fatalf("bad: path should be ./packer/file.iso but it was %s", path) - } + // because of the inplace option; the result file will not be renamed + // sha.ova. os.RemoveAll(step.TargetPath) }