本文整理匯總了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() {