Beispiel #1
0
			models.ServiceOffering{
				Plans: []models.ServicePlanFields{
					models.ServicePlanFields{Name: "service-plan-c"},
					models.ServicePlanFields{Name: "service-plan-d"}},
				ServiceOfferingFields: models.ServiceOfferingFields{
					Label:       "aaa-my-service-offering",
					Description: "service offering 2 description",
				},
			}}
	})

	Context("when the an API endpoint is not targeted", func() {
		It("does not meet its requirements", func() {
			config := testconfig.NewRepository()
			cmd := NewMarketplaceServices(ui, config, serviceRepo)
			requirementsFactory.ApiEndpointSuccess = false

			testcmd.RunCommand(cmd, []string{}, requirementsFactory)
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Context("when the user is logged in", func() {
		BeforeEach(func() {
			config = testconfig.NewRepositoryWithDefaults()
		})

		Context("when the user has a space targeted", func() {
			BeforeEach(func() {
				config.SetSpaceFields(models.SpaceFields{
					Guid: "the-space-guid",
Beispiel #2
0
	Describe("requirements", func() {
		It("fails with usage when given too few arguments", func() {
			testcmd.RunCommand(cmd, []string{}, requirementsFactory)

			Expect(ui.FailedWithUsage).To(BeTrue())
		})

		It("fails if the user has not set an api endpoint", func() {
			testcmd.RunCommand(cmd, []string{"username", "password"}, requirementsFactory)
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Context("when an api endpoint is targeted", func() {
		BeforeEach(func() {
			requirementsFactory.ApiEndpointSuccess = true
			config.SetApiEndpoint("foo.example.org/authenticate")
		})

		It("authenticates successfully", func() {
			requirementsFactory.ApiEndpointSuccess = true
			testcmd.RunCommand(cmd, []string{"*****@*****.**", "password"}, requirementsFactory)

			Expect(ui.FailedWithUsage).To(BeFalse())
			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"foo.example.org/authenticate"},
				[]string{"OK"},
			))

			Expect(repo.AuthenticateArgs.Credentials).To(Equal([]map[string]string{
				{