Fixed unit tests
This commit is contained in:
parent
e26e533e9b
commit
e1aaef1f53
|
@ -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"
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
}
|
||||
|
@ -53,34 +53,4 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
|
|||
if err == nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue