test for 'create_snapshot'

This commit is contained in:
Michael Kuzmin 2017-08-23 23:15:19 +03:00
parent efe2c3c8b3
commit c73f269822
1 changed files with 34 additions and 1 deletions

View File

@ -68,7 +68,7 @@ func checkDefault(t *testing.T, name string, host string) builderT.TestCheckFunc
h := conn.NewHost(vmInfo.Runtime.Host)
hostInfo, err := conn.HostInfo(h, "name")
if err != nil {
t.Fatal("Cannot read VM properties: ", err)
t.Fatal("Cannot read host properties: ", err)
}
if hostInfo.Name != host {
@ -132,6 +132,39 @@ func checkLinkedClone(t *testing.T) builderT.TestCheckFunc {
}
}
func TestBuilderAcc_snapshot(t *testing.T) {
builderT.Test(t, builderT.TestCase{
Builder: &Builder{},
Template: snapshotConfig(),
Check: checkSnapshot(t),
})
}
func snapshotConfig() string {
config := defaultConfig()
config["create_snapshot"] = true
return renderConfig(config)
}
func checkSnapshot(t *testing.T) builderT.TestCheckFunc {
return func(artifacts []packer.Artifact) error {
d := testConn(t)
vm := getVM(t, d, artifacts)
vmInfo, err := d.VMInfo(vm, "layoutEx.disk")
if err != nil {
t.Fatalf("Cannot read VM properties: %v", err)
}
layers := len(vmInfo.LayoutEx.Disk[0].Chain)
if layers != 2 {
t.Errorf("VM should have a single snapshot. expected 2 disk layers, got %v", layers)
}
return nil
}
}
func TestBuilderAcc_template(t *testing.T) {
builderT.Test(t, builderT.TestCase{
Builder: &Builder{},