コード例 #1
0
				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())
		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
0
		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
0
	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",
					}
				})
		})
	})

	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() {