From 3f4f429c3d4bfe576f35499ae8c3280ffea7d47b Mon Sep 17 00:00:00 2001 From: DanHam Date: Fri, 16 Aug 2019 15:48:28 +0100 Subject: [PATCH] Should return an error when artifact file does not have .box extension --- .../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 b5a9f5a5d..b9d8058a1 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -157,6 +157,26 @@ func TestPostProcessor_PostProcess_checkArtifactType(t *testing.T) { } } +func TestPostProcessor_PostProcess_checkArtifactFileIsBox(t *testing.T) { + artifact := &packer.MockArtifact{ + BuilderIdValue: "mitchellh.post-processor.vagrant", // good + FilesValue: []string{"invalid.boxfile"}, // should have .box extension + } + + 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 files in artifact") { + t.Fatalf("Should error with message 'Unknown files in artifact...' with artifact file: %s", + artifact.FilesValue[0]) + } +} + func testUi() *packer.BasicUi { return &packer.BasicUi{ Reader: new(bytes.Buffer),