2014-06-16 15:53:37 -04:00
|
|
|
package vagrantcloud
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
2016-07-30 20:10:16 -04:00
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2014-06-16 15:53:37 -04:00
|
|
|
)
|
|
|
|
|
2014-06-25 10:56:09 -04:00
|
|
|
func testGoodConfig() map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"access_token": "foo",
|
|
|
|
"version_description": "bar",
|
|
|
|
"box_tag": "hashicorp/precise64",
|
|
|
|
"version": "0.5",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testBadConfig() map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"access_token": "foo",
|
|
|
|
"box_tag": "baz",
|
|
|
|
"version_description": "bar",
|
|
|
|
}
|
2014-06-16 15:53:37 -04:00
|
|
|
}
|
|
|
|
|
2014-06-25 10:56:09 -04:00
|
|
|
func TestPostProcessor_Configure_Good(t *testing.T) {
|
2014-06-16 15:53:37 -04:00
|
|
|
var p PostProcessor
|
2014-06-25 10:56:09 -04:00
|
|
|
if err := p.Configure(testGoodConfig()); err != nil {
|
2014-06-16 15:53:37 -04:00
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
2014-06-25 10:56:09 -04:00
|
|
|
}
|
2014-06-16 15:53:37 -04:00
|
|
|
|
2014-06-25 10:56:09 -04:00
|
|
|
func TestPostProcessor_Configure_Bad(t *testing.T) {
|
|
|
|
var p PostProcessor
|
|
|
|
if err := p.Configure(testBadConfig()); err == nil {
|
|
|
|
t.Fatalf("should have err")
|
|
|
|
}
|
2014-06-16 15:53:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func testUi() *packer.BasicUi {
|
|
|
|
return &packer.BasicUi{
|
|
|
|
Reader: new(bytes.Buffer),
|
|
|
|
Writer: new(bytes.Buffer),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPostProcessor_ImplementsPostProcessor(t *testing.T) {
|
|
|
|
var _ packer.PostProcessor = new(PostProcessor)
|
|
|
|
}
|
|
|
|
|
2016-07-30 20:10:16 -04:00
|
|
|
func TestProviderFromBuilderName(t *testing.T) {
|
2014-06-16 15:53:37 -04:00
|
|
|
if providerFromBuilderName("foobar") != "foobar" {
|
|
|
|
t.Fatal("should copy unknown provider")
|
|
|
|
}
|
|
|
|
|
|
|
|
if providerFromBuilderName("vmware") != "vmware_desktop" {
|
|
|
|
t.Fatal("should convert provider")
|
|
|
|
}
|
|
|
|
}
|