|
|
|
|
@ -69,3 +69,55 @@ func TestProvisionerPrepare_PlaybookFile(t *testing.T) {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestProvisionerPrepare_Dirs(t *testing.T) {
|
|
|
|
|
var p Provisioner
|
|
|
|
|
config := testConfig()
|
|
|
|
|
|
|
|
|
|
err := p.Prepare(config)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("should have error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config["playbook_file"] = ""
|
|
|
|
|
err = p.Prepare(config)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("should have error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playbook_file, err := ioutil.TempFile("", "playbook")
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
defer os.Remove(playbook_file.Name())
|
|
|
|
|
|
|
|
|
|
config["playbook_file"] = playbook_file.Name()
|
|
|
|
|
err = p.Prepare(config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config["playbook_paths"] = []string{playbook_file.Name()}
|
|
|
|
|
err = p.Prepare(config)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("should error if playbook paths is not a dir")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config["playbook_paths"] = []string{os.TempDir()}
|
|
|
|
|
err = p.Prepare(config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config["role_paths"] = []string{playbook_file.Name()}
|
|
|
|
|
err = p.Prepare(config)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("should error if role paths is not a dir")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config["role_paths"] = []string{os.TempDir()}
|
|
|
|
|
err = p.Prepare(config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|