Skip to content

Commit

Permalink
Add qcow2 shrink/compress tests for hashicorp#2748
Browse files Browse the repository at this point in the history
  • Loading branch information
markpeek committed Nov 1, 2015
1 parent c2fd83e commit 31dd989
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions builder/qemu/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,48 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
}
}

func TestBuilderPrepare_DiskCompaction(t *testing.T) {
var b Builder
config := testConfig()

// Bad
config["skip_compaction"] = false
config["disk_compression"] = true
config["format"] = "img"
warns, err := b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err == nil {
t.Fatal("should have error")
}
if b.config.SkipCompaction != true {
t.Fatalf("SkipCompaction should be true")
}
if b.config.DiskCompression != false {
t.Fatalf("DiskCompression should be false")
}

// Good
config["skip_compaction"] = false
config["disk_compression"] = true
config["format"] = "qcow2"
b = Builder{}
warns, err = b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.SkipCompaction != false {
t.Fatalf("SkipCompaction should be false")
}
if b.config.DiskCompression != true {
t.Fatalf("DiskCompression should be true")
}
}

func TestBuilderPrepare_DiskSize(t *testing.T) {
var b Builder
config := testConfig()
Expand Down

0 comments on commit 31dd989

Please sign in to comment.