Ejemplo n.º 1
0
		Expect(c.Config.OrganizationFields().Guid).To(Equal(""))
		Expect(c.Config.SpaceFields().Guid).To(Equal(""))
		Expect(c.Config.AccessToken()).To(Equal("my_access_token"))
		Expect(c.Config.RefreshToken()).To(Equal("my_refresh_token"))
	})

	It("TestSuccessfullyLoggingInWithoutTargetSpace", func() {
		c := setUpLoginTestContext()

		c.ui.Inputs = []string{"api.example.com", "*****@*****.**", "password", ""}

		org := models.Organization{}
		org.Guid = "some-org-guid"
		org.Name = "some-org"

		space1 := maker.NewSpace(maker.Overrides{"name": "some-space", "guid": "some-space-guid"})
		space2 := maker.NewSpace(maker.Overrides{"name": "other-space", "guid": "other-space-guid"})

		c.orgRepo.Organizations = []models.Organization{org}
		c.spaceRepo.Spaces = []models.Space{space1, space2}

		callLogin(c)

		testassert.SliceContains(c.ui.Outputs, testassert.Lines{
			{"Select a space (or press enter to skip):"},
		})
		testassert.SliceDoesNotContain(c.ui.Outputs, testassert.Lines{
			{"FAILED"},
		})

		Expect(c.Config.ApiEndpoint()).To(Equal("api.example.com"))
Ejemplo n.º 2
0
	)

	runCommand := func(args ...string) {
		ctxt := testcmd.NewContext("delete-space", args)
		cmd := NewDeleteSpace(ui, config, spaceRepo)
		testcmd.RunCommand(cmd, ctxt, 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