Exemple #1
0
		requirementsFactory *testreq.FakeReqFactory
	)

	runCommand := func(args ...string) {
		cmd := NewDeleteSpace(ui, config, spaceRepo)
		testcmd.RunCommand(cmd, args, requirementsFactory)
		return
	}

	BeforeEach(func() {
		ui = &testterm.FakeUI{}
		spaceRepo = &testapi.FakeSpaceRepository{}
		config = testconfig.NewRepositoryWithDefaults()

		space = maker.NewSpace(maker.Overrides{
			"name": "space-to-delete",
			"guid": "space-to-delete-guid",
		})

		requirementsFactory = &testreq.FakeReqFactory{
			LoginSuccess:       true,
			TargetedOrgSuccess: true,
			Space:              space,
		}
	})

	Describe("requirements", func() {
		BeforeEach(func() {
			ui.Inputs = []string{"y"}
		})
		It("fails when not logged in", func() {
			requirementsFactory.LoginSuccess = false
Exemple #2
0
		userRepo = &testapi.FakeUserRepository{}
		spaceRoleSetter = user.NewSetSpaceRole(ui, configRepo, spaceRepo, userRepo)

		requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
		configOrg = models.OrganizationFields{
			Name: "my-org",
			Guid: "my-org-guid",
		}

		configSpace = models.SpaceFields{
			Name: "config-space",
			Guid: "config-space-guid",
		}

		spaceRepo = &testapi.FakeSpaceRepository{
			CreateSpaceSpace: maker.NewSpace(maker.Overrides{"name": "my-space", "guid": "my-space-guid", "organization": configOrg}),
		}
		Expect(spaceRepo.CreateSpaceSpace.Name).To(Equal("my-space"))
	})

	Describe("Requirements", func() {
		It("fails with usage when no arguments are passed", func() {
			runCommand()
			Expect(ui.FailedWithUsage).To(BeTrue())
		})

		Context("when not logged in", func() {
			BeforeEach(func() {
				requirementsFactory.LoginSuccess = false
			})