func TestDigitalOcean(t *testing.T) { cwd, err := os.Getwd() err = os.Chdir("misc/fixtures/digitalocean") defer os.Chdir(cwd) ui := new(cli.MockUi) exitStatus, err := doIt(ui, []string{"inventory"}) if exitStatus != 0 { t.Error(fmt.Sprintf("exitStatus was %d, expected 0", exitStatus)) } if err != nil { t.Error(fmt.Sprintf("err was \"%s\", expected nil", err)) } inv, err := inventory.NewFromJSON(ui.OutputWriter.String()) if err != nil { fmt.Println("Unable to create inventory from output", err) } inventory.SortInventory(inv) if !reflect.DeepEqual(inv, do_expected_list_inventory()) { t.Error(fmt.Sprintf("Output was not as expected.\n%s", ui.OutputWriter.String())) } }
func TestOpenStackWithDir(t *testing.T) { ui := new(cli.MockUi) exitStatus, err := doIt(ui, []string{"inventory", "-dir", "misc/fixtures/openstack"}) if exitStatus != 0 { t.Error(fmt.Sprintf("exitStatus was %d, expected 0", exitStatus)) } if err != nil { t.Error(fmt.Sprintf("err was \"%s\", expected nil", err)) } inv, err := inventory.NewFromJSON(ui.OutputWriter.String()) if err != nil { fmt.Println("Unable to create inventory from output", err) } inventory.SortInventory(inv) if !reflect.DeepEqual(inv, os_expected_list_inventory()) { t.Error(fmt.Sprintf("Output was not as expected.\n%s", ui.OutputWriter.String())) } }