Commit 607372f7 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/chef-solo: massive refactor and style nitpick

parent 4a5a8c60
This diff is collapsed.
......@@ -8,9 +8,7 @@ import (
)
func testConfig() map[string]interface{} {
return map[string]interface{}{
// "inline": []interface{}{"foo", "bar"},
}
return map[string]interface{}{}
}
func TestProvisioner_Impl(t *testing.T) {
......@@ -21,48 +19,35 @@ func TestProvisioner_Impl(t *testing.T) {
}
}
// Cookbook paths
//////////////////
func TestProvisionerPrepare_DefaultCookbookPathIsUsed(t *testing.T) {
var p Provisioner
config := testConfig()
err := p.Prepare(config)
if err == nil {
t.Errorf("expected error to be thrown for unavailable cookbook path")
}
if len(p.config.CookbooksPaths) != 1 || p.config.CookbooksPaths[0] != DefaultCookbooksPath {
t.Errorf("unexpected default cookbook path: %s", p.config.CookbooksPaths)
}
}
func TestProvisionerPrepare_GivenCookbookPathsAreAddedToConfig(t *testing.T) {
func TestProvisionerPrepare_cookbookPaths(t *testing.T) {
var p Provisioner
path1, err := ioutil.TempDir("", "cookbooks_one")
if err != nil {
t.Errorf("err: %s", err)
t.Fatalf("err: %s", err)
}
path2, err := ioutil.TempDir("", "cookbooks_two")
if err != nil {
t.Errorf("err: %s", err)
t.Fatalf("err: %s", err)
}
defer os.Remove(path1)
defer os.Remove(path2)
config := testConfig()
config["cookbooks_paths"] = []string{path1, path2}
config["cookbook_paths"] = []string{path1, path2}
err = p.Prepare(config)
if err != nil {
t.Errorf("err: %s", err)
t.Fatalf("err: %s", err)
}
if len(p.config.CookbookPaths) != 2 {
t.Fatalf("unexpected: %#v", p.config.CookbookPaths)
}
if len(p.config.CookbooksPaths) != 2 || p.config.CookbooksPaths[0] != path1 || p.config.CookbooksPaths[1] != path2 {
t.Errorf("unexpected default cookbook path: %s", p.config.CookbooksPaths)
if p.config.CookbookPaths[0] != path1 || p.config.CookbookPaths[1] != path2 {
t.Fatalf("unexpected: %#v", p.config.CookbookPaths)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment