本文整理汇总了Golang中github.com/cloudfoundry-community/bosh-softlayer-tools/cmds.Command.Execute方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Execute方法的具体用法?Golang Command.Execute怎么用?Golang Command.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-community/bosh-softlayer-tools/cmds.Command
的用法示例。
在下文中一共展示了Command.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
validate, err := cmd.Validate()
Expect(validate).To(BeFalse())
Expect(err).To(HaveOccurred())
})
})
})
Describe("#Execute", func() {
Context("executes a good BmsCommand", func() {
BeforeEach(func() {
fakeBmpClient.BmsResponse.Status = 200
fakeBmpClient.BmsErr = nil
})
It("executes with no error", func() {
rc, err := cmd.Execute([]string{"bmp", "bms"})
Expect(rc).To(Equal(0))
Expect(err).ToNot(HaveOccurred())
})
})
Context("executes a bad Bmscommand", func() {
BeforeEach(func() {
fakeBmpClient.BmsResponse.Status = 404
fakeBmpClient.BmsErr = errors.New("fake-error")
})
It("executes with error", func() {
rc, err := cmd.Execute([]string{"bmp", "bms"})
Expect(rc).To(Equal(404))
Expect(err).To(HaveOccurred())
示例2:
It("validates a good StemcellsCommand", func() {
validate, err := cmd.Validate()
Expect(validate).To(BeTrue())
Expect(err).ToNot(HaveOccurred())
})
})
Describe("#Execute", func() {
Context("executes a good StemcellsCommand", func() {
BeforeEach(func() {
fakeBmpClient.StemcellsResponse.Status = 200
fakeBmpClient.StemcellsErr = nil
})
It("execute with no error", func() {
rc, err := cmd.Execute(args)
Expect(rc).To(Equal(0))
Expect(err).ToNot(HaveOccurred())
})
})
Context("executes a bad StemcellsCommand", func() {
Context("executes StemcellsCommand with error", func() {
BeforeEach(func() {
fakeBmpClient.StemcellsResponse.Status = 500
fakeBmpClient.StemcellsErr = errors.New("500")
})
It("executes with error", func() {
rc, err := cmd.Execute(args)
Expect(rc).To(Equal(1))
示例3:
Context("with JSON format", func() {
Context("executes a good TaskCommand", func() {
Context("when a default event level is passed", func() {
BeforeEach(func() {
fakeBmpClient.TaskOutputResponse.Status = 200
fakeBmpClient.TaskOutputErr = nil
options = cmds.Options{
Verbose: false,
TaskID: 1,
Debug: false,
JSON: true,
}
})
It("executes without errors", func() {
rc, err := cmd.Execute([]string{"bmp", "task", "--task_id=1"})
Expect(rc).To(Equal(0))
Expect(err).ToNot(HaveOccurred())
})
})
Context("when debug level is passed", func() {
BeforeEach(func() {
fakeBmpClient.TaskOutputResponse.Status = 200
fakeBmpClient.TaskOutputErr = nil
options = cmds.Options{
Verbose: false,
TaskID: 1,
Debug: true,
JSON: true,
}
示例4:
Describe("#Execute", func() {
Context("executes a good SlCommand", func() {
Context("when executes sl --packages", func() {
BeforeEach(func() {
fakeBmpClient.SlPackagesResponse.Status = 200
fakeBmpClient.SlPackagesErr = nil
options = cmds.Options{
Verbose: false,
Packages: true,
}
})
It("executes without errors", func() {
cmd = bmp.NewSlCommand(options, fakeBmpClient)
rc, err := cmd.Execute([]string{"bmp", "sl", "--packages"})
Expect(rc).To(Equal(0))
Expect(err).ToNot(HaveOccurred())
})
})
Context("when executes sl --package-options 1", func() {
BeforeEach(func() {
fakeBmpClient.SlPackageOptionsResponse.Status = 200
fakeBmpClient.SlPackageOptionsErr = nil
options = cmds.Options{
Verbose: false,
PackageOptions: "1",
}
})
示例5:
})
})
Describe("#Execute", func() {
Context("executes a good TasksCommand", func() {
BeforeEach(func() {
fakeBmpClient.TasksResponse.Status = 200
fakeBmpClient.TasksErr = nil
options = cmds.Options{
Verbose: false,
Latest: 1,
}
})
It("executes a good TasksCommand without specifying latest", func() {
rc, err := cmd.Execute([]string{"bmp", "tasks"})
Expect(rc).To(Equal(0))
Expect(err).ToNot(HaveOccurred())
})
It("executes a good TasksCommand with specifying latest", func() {
cmd = bmp.NewTasksCommand(options, fakeBmpClient)
rc, err := cmd.Execute([]string{"bmp", "tasks", "--latest=1"})
Expect(rc).To(Equal(0))
Expect(err).ToNot(HaveOccurred())
})
})
Context("executes a bad TasksCommand", func() {
Context("executes TasksCommand with error", func() {