Fixed unit tests

This commit is contained in:
jasminSPC 2016-08-01 13:30:28 +02:00
parent e26e533e9b
commit e1aaef1f53
2 changed files with 7 additions and 37 deletions

View File

@ -29,9 +29,9 @@ const testBuilderAccBasic = `
{
"builders": [{
"image": "Ubuntu-16.04",
"pbpassword": "password",
"pbusername": "username",
"servername": "packer",
"password": "password",
"username": "username",
"snapshot_name": "packer",
"type": "profitbricks"
}]
}

View File

@ -9,9 +9,9 @@ import (
func testConfig() map[string]interface{} {
return map[string]interface{}{
"image": "Ubuntu-16.04",
"pbpassword": "password",
"pbusername": "username",
"servername": "packer",
"password": "password",
"username": "username",
"snapshot_name": "packer",
"type": "profitbricks",
}
}
@ -54,33 +54,3 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
t.Fatal("should have error")
}
}
func TestBuilderPrepare_Servername(t *testing.T) {
var b Builder
config := testConfig()
delete(config, "servername")
warnings, err := b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err == nil {
t.Fatalf("should error")
}
expected := "packer"
config["servername"] = expected
b = Builder{}
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.SnapshotName != expected {
t.Errorf("found %s, expected %s", b.config.SnapshotName, expected)
}
}