Should return an error with an invalid BuilderId

This commit is contained in:
DanHam 2019-08-16 15:42:56 +01:00
parent 17d9a85895
commit 57308b0126
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 20 additions and 0 deletions

View File

@ -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),