func createCommands(options cmds.Options, bmpClient clients.BmpClient) map[string]cmds.Command { return map[string]cmds.Command{ "bms": bmp.NewBmsCommand(options, bmpClient), "create-baremetals": bmp.NewCreateBaremetalsCommand(options, bmpClient), "login": bmp.NewLoginCommand(options, bmpClient), "sl": bmp.NewSlCommand(options, bmpClient), "status": bmp.NewStatusCommand(options, bmpClient), "stemcells": bmp.NewStemcellsCommand(options, bmpClient), "target": bmp.NewTargetCommand(options, bmpClient), "task": bmp.NewTaskCommand(options, bmpClient), "tasks": bmp.NewTasksCommand(options, bmpClient), "update-state": bmp.NewUpdateStateCommand(options, bmpClient), "provisioning-baremetal": bmp.NewProvisioningBaremetalCommand(options, bmpClient), } }
Target: "http://fake.url", } tmpDir, err = ioutil.TempDir("", "bmp-target-execute") Expect(err).ToNot(HaveOccurred()) tmpFile, err := ioutil.TempFile(tmpDir, ".bmp_config") Expect(err).ToNot(HaveOccurred()) tmpFileName = tmpFile.Name() err = ioutil.WriteFile(tmpFileName, []byte("{}"), 0666) Expect(err).ToNot(HaveOccurred()) fakeBmpClient = clientsfakes.NewFakeBmpClient(options.Username, options.Password, options.Target, tmpFileName) cmd = bmp.NewTargetCommand(options, fakeBmpClient) }) AfterEach(func() { err := os.RemoveAll(tmpDir) Expect(err).ToNot(HaveOccurred()) }) Describe("NewTargetCommand", func() { It("create new TargetCommand", func() { Expect(cmd).ToNot(BeNil()) cmd2 := bmp.NewTargetCommand(options, fakeBmpClient) Expect(cmd2).ToNot(BeNil()) Expect(cmd2).To(Equal(cmd)) })