Ejemplo n.º 1
0
		callListDomains([]string{}, reqFactory, domainRepo)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
	})

	It("TestListDomainsFailsWithUsage", func() {
		reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
		domainRepo := &testapi.FakeDomainRepository{}

		ui := callListDomains([]string{"foo"}, reqFactory, domainRepo)
		Expect(ui.FailedWithUsage).To(BeTrue())
	})

	It("TestListDomains", func() {
		orgFields := models.OrganizationFields{}
		orgFields.Name = "my-org"
		orgFields.Guid = "my-org-guid"

		reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, OrganizationFields: orgFields}
		domain1 := models.DomainFields{}
		domain1.Shared = true
		domain1.Name = "Domain1"

		domain2 := models.DomainFields{}
		domain2.Shared = false
		domain2.Name = "Domain2"

		domain3 := models.DomainFields{}
		domain3.Shared = false
		domain3.Name = "Domain3"

		domainRepo := &testapi.FakeDomainRepository{
Ejemplo n.º 2
0
			sf.Guid = "guid"
			sf.Name = "name"

			output := captureOutput(func() {
				ui := NewUI(os.Stdin)
				ui.ShowConfiguration(config)
			})

			testassert.SliceContains(output, testassert.Lines{
				{"No", "org", "targeted", "-o ORG"},
			})
		})

		It("prompts the user to target a space when no space is targeted", func() {
			of := models.OrganizationFields{}
			of.Guid = "of-guid"
			of.Name = "of-name"

			output := captureOutput(func() {
				ui := NewUI(os.Stdin)
				ui.ShowConfiguration(config)
			})

			testassert.SliceContains(output, testassert.Lines{
				{"No", "space", "targeted", "-s SPACE"},
			})
		})
	})

	Describe("failing", func() {
		It("panics with a specific string", func() {
Ejemplo n.º 3
0
import (
	"cf/models"
	. "cf/requirements"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	testassert "testhelpers/assert"
	testconfig "testhelpers/configuration"
	testterm "testhelpers/terminal"
)

var _ = Describe("Testing with ginkgo", func() {
	It("TestSpaceRequirement", func() {
		ui := new(testterm.FakeUI)
		org := models.OrganizationFields{}
		org.Name = "my-org"
		org.Guid = "my-org-guid"
		space := models.SpaceFields{}
		space.Name = "my-space"
		space.Guid = "my-space-guid"
		config := testconfig.NewRepositoryWithDefaults()

		req := NewTargetedSpaceRequirement(ui, config)
		success := req.Execute()
		Expect(success).To(BeTrue())

		config.SetSpaceFields(models.SpaceFields{})

		testassert.AssertPanic(testterm.FailedWasCalled, func() {
			NewTargetedSpaceRequirement(ui, config).Execute()
		})
Ejemplo n.º 4
0
		})

		Context("when deleting the currently targeted org", func() {
			It("untargets the deleted org", func() {
				config.SetOrganizationFields(orgRepo.Organizations[0].OrganizationFields)
				runCommand("org-to-delete")

				Expect(config.OrganizationFields()).To(Equal(models.OrganizationFields{}))
				Expect(config.SpaceFields()).To(Equal(models.SpaceFields{}))
			})
		})

		Context("when deleting an org that is not targeted", func() {
			BeforeEach(func() {
				otherOrgFields := models.OrganizationFields{}
				otherOrgFields.Guid = "some-other-org-guid"
				otherOrgFields.Name = "some-other-org"
				config.SetOrganizationFields(otherOrgFields)

				spaceFields := models.SpaceFields{}
				spaceFields.Name = "some-other-space"
				config.SetSpaceFields(spaceFields)
			})

			It("deletes the org with the given name", func() {
				runCommand("org-to-delete")

				testassert.SliceContains(ui.Prompts, testassert.Lines{
					{"Really delete the org org-to-delete"},
				})