From e8336039d9e393b1a4d4df231c8598af20f3d6dc Mon Sep 17 00:00:00 2001 From: DanHam Date: Wed, 21 Aug 2019 13:31:29 +0100 Subject: [PATCH] Should return provider correctly with good box and artifice pp --- .../vagrant-cloud/post-processor_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/post-processor/vagrant-cloud/post-processor_test.go b/post-processor/vagrant-cloud/post-processor_test.go index c698db017..6a0d9c4cb 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -386,6 +386,24 @@ func TestProviderFromVagrantBox_metadata_ok(t *testing.T) { t.Logf("Expected provider '%s'. Got provider '%s'", expectedProvider, provider) } +func TestGetProvider_artifice(t *testing.T) { + expectedProvider := "virtualbox" + files := tarFiles{ + {"foo.txt", "This is a foo file"}, + {"bar.txt", "This is a bar file"}, + {"metadata.json", `{"provider":"` + expectedProvider + `"}`}, + } + boxfile, err := createBox(files) + if err != nil { + t.Fatalf("Error creating test box: %s", err) + } + defer os.Remove(boxfile.Name()) + + provider, err := getProvider("", boxfile.Name(), "artifice") + assert.Equal(t, expectedProvider, provider, "Error: Expected provider: '%s'. Got '%s'", expectedProvider, provider) + t.Logf("Expected provider '%s'. Got provider '%s'", expectedProvider, provider) +} + func newBoxFile() (boxfile *os.File, err error) { boxfile, err = ioutil.TempFile(os.TempDir(), "test*.box") if err != nil {