From e8bac9f4c8f52650827e9406e3bf2a8b89dffdb4 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sat, 23 Dec 2017 23:46:30 -0600 Subject: [PATCH] Add unit tests for new vagrant Google post-processor --- post-processor/vagrant/google_test.go | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 post-processor/vagrant/google_test.go diff --git a/post-processor/vagrant/google_test.go b/post-processor/vagrant/google_test.go new file mode 100644 index 000000000..a66be8539 --- /dev/null +++ b/post-processor/vagrant/google_test.go @@ -0,0 +1,36 @@ +package vagrant + +import ( + "github.com/hashicorp/packer/packer" + "strings" + "testing" +) + +func TestGoogleProvider_impl(t *testing.T) { + var _ Provider = new(GoogleProvider) +} + +func TestGoogleProvider_KeepInputArtifact(t *testing.T) { + p := new(GoogleProvider) + + if !p.KeepInputArtifact() { + t.Fatal("should keep input artifact") + } +} + +func TestGoogleProvider_ArtifactId(t *testing.T) { + p := new(GoogleProvider) + ui := testUi() + artifact := &packer.MockArtifact{ + IdValue: "packer-1234", + } + + vagrantfile, _, err := p.Process(ui, artifact, "foo") + if err != nil { + t.Fatalf("should not have error: %s", err) + } + result := `google.image = "packer-1234"` + if !strings.Contains(vagrantfile, result) { + t.Fatalf("wrong substitution: %s", vagrantfile) + } +}