From 4f952613d75bf5becb37c6fbe6e7f9eeac7102d9 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Wed, 7 Nov 2018 23:58:04 +0300 Subject: [PATCH] Add 'notes' tests --- clone/builder_acc_test.go | 34 ++++++++++++++++++++++++++++++++++ iso/builder_acc_test.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/clone/builder_acc_test.go b/clone/builder_acc_test.go index 95649ca7c..63610233c 100644 --- a/clone/builder_acc_test.go +++ b/clone/builder_acc_test.go @@ -577,3 +577,37 @@ func checkBootOrder(t *testing.T) builderT.TestCheckFunc { return nil } } + +func TestCloneBuilderAcc_notes(t *testing.T) { + builderT.Test(t, builderT.TestCase{ + Builder: &Builder{}, + Template: notesConfig(), + Check: checkNotes(t), + }) +} + +func notesConfig() string { + config := defaultConfig() + config["notes"] = "test" + + return commonT.RenderConfig(config) +} + +func checkNotes(t *testing.T) builderT.TestCheckFunc { + return func(artifacts []packer.Artifact) error { + d := commonT.TestConn(t) + vm := commonT.GetVM(t, d, artifacts) + + vmInfo, err := vm.Info("config.annotation") + if err != nil { + t.Fatalf("Cannot read VM properties: %v", err) + } + + notes := vmInfo.Config.Annotation + if notes != "test" { + t.Errorf("notest should be 'test'") + } + + return nil + } +} diff --git a/iso/builder_acc_test.go b/iso/builder_acc_test.go index 21f9fc5b4..d893568a6 100644 --- a/iso/builder_acc_test.go +++ b/iso/builder_acc_test.go @@ -110,6 +110,40 @@ func checkDefault(t *testing.T, name string, host string, datastore string) buil } } +func TestISOBuilderAcc_notes(t *testing.T) { + builderT.Test(t, builderT.TestCase{ + Builder: &Builder{}, + Template: notesConfig(), + Check: checkNotes(t), + }) +} + +func notesConfig() string { + config := defaultConfig() + config["notes"] = "test" + + return commonT.RenderConfig(config) +} + +func checkNotes(t *testing.T) builderT.TestCheckFunc { + return func(artifacts []packer.Artifact) error { + d := commonT.TestConn(t) + vm := commonT.GetVM(t, d, artifacts) + + vmInfo, err := vm.Info("config.annotation") + if err != nil { + t.Fatalf("Cannot read VM properties: %v", err) + } + + notes := vmInfo.Config.Annotation + if notes != "test" { + t.Errorf("notes should be 'test'") + } + + return nil + } +} + func TestISOBuilderAcc_hardware(t *testing.T) { builderT.Test(t, builderT.TestCase{ Builder: &Builder{},