From 57308b01261067f8d3eb7317a866f24d595e5cf0 Mon Sep 17 00:00:00 2001 From: DanHam Date: Fri, 16 Aug 2019 15:42:56 +0100 Subject: [PATCH] Should return an error with an invalid BuilderId --- .../vagrant-cloud/post-processor_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/post-processor/vagrant-cloud/post-processor_test.go b/post-processor/vagrant-cloud/post-processor_test.go index 5649aca4c..b5a9f5a5d 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -2,10 +2,12 @@ package vagrantcloud import ( "bytes" + "context" "fmt" "net/http" "net/http/httptest" "os" + "strings" "testing" "github.com/hashicorp/packer/packer" @@ -137,6 +139,24 @@ func TestPostProcessor_Configure_Bad(t *testing.T) { } } +func TestPostProcessor_PostProcess_checkArtifactType(t *testing.T) { + artifact := &packer.MockArtifact{ + BuilderIdValue: "invalid.builder", + } + + config := testGoodConfig() + server := newSecureServer("foo", nil) + defer server.Close() + config["vagrant_cloud_url"] = server.URL + var p PostProcessor + + p.Configure(config) + _, _, _, err := p.PostProcess(context.Background(), testUi(), artifact) + if !strings.Contains(err.Error(), "Unknown artifact type") { + t.Fatalf("Should error with message 'Unknown artifact type...' with BuilderId: %s", artifact.BuilderIdValue) + } +} + func testUi() *packer.BasicUi { return &packer.BasicUi{ Reader: new(bytes.Buffer),