Exemple #1
0
func createCommand(args []string, options cmds.Options) (cmds.Command, error) {
	if len(args) < 2 {
		return nil, errors.New("No bmp command specified")
	}

	var command cmds.Command

	cmdName := args[1]
	switch cmdName {
	case "bms":
		command = cmds.NewBmsCommand(options)
		break

	case "create-baremetals":
		command = cmds.NewCreateBaremetalsCommand(options)
		break

	case "login":
		command = cmds.NewLoginCommand(options)
		break

	case "sl-package-options":
		command = cmds.NewSlPackageOptionsCommand(options)
		break

	case "sl-packages":
		command = cmds.NewSlPackagesCommand(options)
		break

	case "status":
		command = cmds.NewStatusCommand(options)
		break

	case "stemcells":
		command = cmds.NewStemcellsCommand(options)
		break

	case "target":
		command = cmds.NewTargetCommand(options)
		break

	case "task":
		command = cmds.NewTaskCommand(options)
		break

	case "tasks":
		command = cmds.NewTasksCommand(options)
		break

	case "update-state":
		command = cmds.NewUpdateStateCommand(options)
		break

	default:
		return nil, errors.New(fmt.Sprintf("Unknown bmp command: %s", cmdName))
	}

	return command, nil
}
)

var _ = Describe("tasks command", func() {
	var (
		args    []string
		options cmds.Options
		cmd     cmds.Command
	)

	BeforeEach(func() {
		args = []string{"bmp", "tasks"}
		options = cmds.Options{
			Verbose: false,
		}

		cmd = cmds.NewTasksCommand(options)
	})

	Describe("NewTasksCommand", func() {
		It("create new TasksCommand", func() {
			Expect(cmd).ToNot(BeNil())

			cmd2 := cmds.NewTasksCommand(options)
			Expect(cmd2).ToNot(BeNil())
			Expect(cmd2).To(Equal(cmd))
		})
	})

	Describe("#Name", func() {
		It("returns the name of a TasksCommand", func() {
			Expect(cmd.Name()).To(Equal("tasks"))