Пример #1
0
		requirementsFactory *requirementsfakes.FakeFactory
		deps                commandregistry.Dependency
	)

	updateCommandDependency := func(pluginCall bool) {
		deps.UI = ui
		deps.RepoLocator = deps.RepoLocator.SetRouteRepository(routeRepo).SetDomainRepository(domainRepo)
		deps.Config = configRepo
		commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("routes").SetDependency(deps, pluginCall))
	}

	BeforeEach(func() {
		ui = &testterm.FakeUI{}
		configRepo = testconfig.NewRepositoryWithDefaults()
		requirementsFactory = new(requirementsfakes.FakeFactory)
		requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
		routeRepo = new(apifakes.FakeRouteRepository)
		domainRepo = new(apifakes.FakeDomainRepository)
	})

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("routes", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	Describe("login requirements", func() {
		It("fails if the user is not logged in", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
			Expect(runCommand()).To(BeFalse())
		})
Пример #2
0
			return models.Application{}, fmt.Errorf("Called stubbed applications repo GetApp with incorrect app GUID\nExpected \"app1-guid\"\nGot \"%s\"\n", appGUID)
		}

		deps = commandregistry.Dependency{
			UI:           ui,
			PluginModels: &commandregistry.PluginModels{},
			RepoLocator:  api.RepositoryLocator{}.SetApplicationRepository(appRepo),
		}

		cmd = &service.ShowService{}

		flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
		reqFactory = new(requirementsfakes.FakeFactory)

		loginRequirement = &passingRequirement{Name: "login-requirement"}
		reqFactory.NewLoginRequirementReturns(loginRequirement)
		targetedSpaceRequirement = &passingRequirement{Name: "targeted-space-requirement"}
		reqFactory.NewTargetedSpaceRequirementReturns(targetedSpaceRequirement)
		serviceInstanceRequirement = &requirementsfakes.FakeServiceInstanceRequirement{}
		reqFactory.NewServiceInstanceRequirementReturns(serviceInstanceRequirement)
	})

	Describe("Requirements", func() {
		BeforeEach(func() {
			cmd.SetDependency(deps, pluginCall)
		})

		Context("when not provided exactly 1 argument", func() {
			It("fails", func() {
				err := flagContext.Parse("too", "many")
				Expect(err).NotTo(HaveOccurred())
Пример #3
0
		buildpackName string
	)

	updateCommandDependency := func(pluginCall bool) {
		deps.UI = ui
		deps.RepoLocator = deps.RepoLocator.SetBuildpackRepository(repo)
		deps.RepoLocator = deps.RepoLocator.SetBuildpackBitsRepository(bitsRepo)
		commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("update-buildpack").SetDependency(deps, pluginCall))
	}

	BeforeEach(func() {
		buildpackName = "my-buildpack"

		requirementsFactory = new(requirementsfakes.FakeFactory)
		requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		buildpackReq := new(requirementsfakes.FakeBuildpackRequirement)
		buildpackReq.GetBuildpackReturns(models.Buildpack{Name: buildpackName})
		requirementsFactory.NewBuildpackRequirementReturns(buildpackReq)
		ui = new(testterm.FakeUI)
		repo = new(apifakes.OldFakeBuildpackRepository)
		bitsRepo = new(apifakes.OldFakeBuildpackBitsRepository)
	})

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("update-buildpack", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	Context("is only successful on login and buildpack success", func() {
		It("returns success when both are true", func() {
			Expect(runCommand(buildpackName)).To(BeTrue())