|
|
|
|
@ -24,11 +24,21 @@ MD5 (other.iso) = bAr
|
|
|
|
|
MD5 (the-OS.iso) = baZ
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var cs_bsd_style_subdir = `
|
|
|
|
|
MD5 (other.iso) = bAr
|
|
|
|
|
MD5 (./subdir/the-OS.iso) = baZ
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var cs_gnu_style = `
|
|
|
|
|
bAr0 *the-OS.iso
|
|
|
|
|
baZ0 other.iso
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var cs_gnu_style_subdir = `
|
|
|
|
|
bAr0 *./subdir/the-OS.iso
|
|
|
|
|
baZ0 other.iso
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
var cs_bsd_style_no_newline = `
|
|
|
|
|
MD5 (other.iso) = bAr
|
|
|
|
|
MD5 (the-OS.iso) = baZ`
|
|
|
|
|
@ -134,6 +144,27 @@ func TestISOConfigPrepare_ISOChecksumURL(t *testing.T) {
|
|
|
|
|
t.Fatalf("should've found \"baz\" got: %s", i.ISOChecksum)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test good - ISOChecksumURL BSD style with relative path
|
|
|
|
|
i = testISOConfig()
|
|
|
|
|
i.ISOChecksum = ""
|
|
|
|
|
|
|
|
|
|
cs_dir, _ := ioutil.TempDir("", "packer-testdir-")
|
|
|
|
|
cs_file, _ = ioutil.TempFile(cs_dir, "packer-test-")
|
|
|
|
|
ioutil.WriteFile(cs_file.Name(), []byte(cs_bsd_style_subdir), 0666)
|
|
|
|
|
i.ISOChecksumURL = fmt.Sprintf("%s%s", filePrefix, cs_file.Name())
|
|
|
|
|
i.RawSingleISOUrl = fmt.Sprintf("%s%s", cs_dir, "/subdir/the-OS.iso")
|
|
|
|
|
warns, err = i.Prepare(nil)
|
|
|
|
|
if len(warns) > 0 {
|
|
|
|
|
t.Fatalf("bad: %#v", warns)
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if i.ISOChecksum != "baz" {
|
|
|
|
|
t.Fatalf("should've found \"baz\" got: %s", i.ISOChecksum)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test good - ISOChecksumURL GNU style no newline
|
|
|
|
|
i = testISOConfig()
|
|
|
|
|
i.ISOChecksum = ""
|
|
|
|
|
@ -171,6 +202,26 @@ func TestISOConfigPrepare_ISOChecksumURL(t *testing.T) {
|
|
|
|
|
if i.ISOChecksum != "bar0" {
|
|
|
|
|
t.Fatalf("should've found \"bar0\" got: %s", i.ISOChecksum)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test good - ISOChecksumURL GNU style with relative path
|
|
|
|
|
i = testISOConfig()
|
|
|
|
|
i.ISOChecksum = ""
|
|
|
|
|
|
|
|
|
|
cs_file, _ = ioutil.TempFile(cs_dir, "packer-test-")
|
|
|
|
|
ioutil.WriteFile(cs_file.Name(), []byte(cs_gnu_style_subdir), 0666)
|
|
|
|
|
i.ISOChecksumURL = fmt.Sprintf("%s%s", filePrefix, cs_file.Name())
|
|
|
|
|
i.RawSingleISOUrl = fmt.Sprintf("%s%s", cs_dir, "/subdir/the-OS.iso")
|
|
|
|
|
warns, err = i.Prepare(nil)
|
|
|
|
|
if len(warns) > 0 {
|
|
|
|
|
t.Fatalf("bad: %#v", warns)
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if i.ISOChecksum != "bar0" {
|
|
|
|
|
t.Fatalf("should've found \"bar0\" got: %s", i.ISOChecksum)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestISOConfigPrepare_ISOChecksumType(t *testing.T) {
|
|
|
|
|
|