var cmd commandregistry.Command var flagContext flags.FlagContext BeforeEach(func() { cmd = &buildpack.ListBuildpacks{} cmd.SetDependency(deps, false) flagContext = flags.NewFlagContext(cmd.MetaData().Flags) }) It("should fail with usage", func() { flagContext.Parse("blahblah") reqs, err := cmd.Requirements(requirementsFactory, flagContext) Expect(err).NotTo(HaveOccurred()) err = testcmd.RunRequirements(reqs) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Incorrect Usage")) Expect(err.Error()).To(ContainSubstring("No argument required")) }) }) It("fails requirements when login fails", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"}) Expect(runCommand()).To(BeFalse()) }) Context("when logged in", func() { BeforeEach(func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) })
var cmd commandregistry.Command var flagContext flags.FlagContext BeforeEach(func() { cmd = &application.ListApps{} cmd.SetDependency(deps, false) flagContext = flags.NewFlagContext(cmd.MetaData().Flags) }) It("requires the user to be logged in", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"}) reqs, err := cmd.Requirements(requirementsFactory, flagContext) Expect(err).NotTo(HaveOccurred()) Expect(testcmd.RunRequirements(reqs)).To(HaveOccurred()) }) It("requires the user to have a space targeted", func() { requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Failing{Message: "not targeting space"}) reqs, err := cmd.Requirements(requirementsFactory, flagContext) Expect(err).NotTo(HaveOccurred()) Expect(testcmd.RunRequirements(reqs)).To(HaveOccurred()) }) It("should fail with usage when provided any arguments", func() { requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{}) flagContext.Parse("blahblah")