Ejemplo n.º 1
0
		})

		It("does not pass requirements", func() {
			Expect(runCommand("-n", "my-host", "example.com")).To(BeFalse())
		})
	})

	Context("when logged in successfully", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
			route := models.Route{Guid: "route-guid"}
			route.Domain = models.DomainFields{
				Guid: "domain-guid",
				Name: "example.com",
			}
			routeRepo.FindReturns(route, nil)
		})

		It("fails with usage when given zero args", func() {
			runCommand()
			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Incorrect Usage", "Requires an argument"},
			))
		})

		It("does not fail with usage when provided with a domain", func() {
			runCommand("example.com")
			Expect(ui.FailedWithUsage).To(BeFalse())
		})

		It("does not fail with usage when provided a hostname", func() {
Ejemplo n.º 2
0
				Expect(err).NotTo(HaveOccurred())
				_, err = cmd.Requirements(factory, flagContext)
				Expect(err).NotTo(HaveOccurred())
			})

			It("tries to find the route with the path", func() {
				cmd.Execute(flagContext)
				Expect(routeRepo.FindCallCount()).To(Equal(1))
				_, _, path := routeRepo.FindArgsForCall(0)
				Expect(path).To(Equal("the-path"))
			})
		})

		Context("when the route can be found", func() {
			BeforeEach(func() {
				routeRepo.FindReturns(models.Route{Guid: "route-guid"}, nil)
			})

			It("tells the user that it is removing the route", func() {
				cmd.Execute(flagContext)
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Removing route", "from app", "in org"},
				))
			})

			Context("when the returned route has an app with the requested app's guid", func() {
				BeforeEach(func() {
					route := models.Route{
						Guid: "route-guid",
						Apps: []models.ApplicationFields{
							{Guid: "fake-app-guid"},
Ejemplo n.º 3
0
					_, err = cmd.Requirements(factory, flagContext)
					Expect(err).NotTo(HaveOccurred())
				})

				It("tries to find the route with the path", func() {
					cmd.Execute(flagContext)
					Expect(routeRepo.FindCallCount()).To(Equal(1))
					_, _, path := routeRepo.FindArgsForCall(0)
					Expect(path).To(Equal("the-path"))
				})
			})

			Context("when the route can be found", func() {
				BeforeEach(func() {
					routeRepo.FindReturns(models.Route{
						Guid: "route-guid",
					}, nil)
				})

				It("tries to delete the route", func() {
					cmd.Execute(flagContext)
					Expect(routeRepo.DeleteCallCount()).To(Equal(1))
					Expect(routeRepo.DeleteArgsForCall(0)).To(Equal("route-guid"))
				})

				Context("when deleting the route succeeds", func() {
					BeforeEach(func() {
						routeRepo.DeleteReturns(nil)
					})

					It("tells the user that it succeeded", func() {
Ejemplo n.º 4
0
			Expect(space).To(Equal("space-guid"))
		})

		Context("when creating the route fails", func() {
			BeforeEach(func() {
				routeRepo.CreateInSpaceReturns(models.Route{}, errors.New("create-error"))
			})

			It("attempts to find the route", func() {
				Expect(func() { cmd.Execute(flagContext) }).To(Panic())
				Expect(routeRepo.FindCallCount()).To(Equal(1))
			})

			Context("when finding the route fails", func() {
				BeforeEach(func() {
					routeRepo.FindReturns(models.Route{}, errors.New("find-error"))
				})

				It("fails with the original error", func() {
					Expect(func() { cmd.Execute(flagContext) }).To(Panic())
					Expect(ui.Outputs).To(ContainSubstrings([]string{"FAILED"}, []string{"create-error"}))
				})
			})

			Context("when a route with the same space guid, but different domain guid is found", func() {
				It("fails with the original error", func() {
					Expect(func() { cmd.Execute(flagContext) }).To(Panic())
					Expect(ui.Outputs).To(ContainSubstrings([]string{"FAILED"}, []string{"create-error"}))
				})
			})
				flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
				err := flagContext.Parse("domain-name", "service-instance", "-n", "the-hostname")
				Expect(err).NotTo(HaveOccurred())
			})

			It("tries to find the route with the given hostname", func() {
				cmd.Execute(flagContext)
				Expect(routeRepo.FindCallCount()).To(Equal(1))
				host, _, _ := routeRepo.FindArgsForCall(0)
				Expect(host).To(Equal("the-hostname"))
			})
		})

		Context("when the route can be found", func() {
			BeforeEach(func() {
				routeRepo.FindReturns(models.Route{Guid: "route-guid"}, nil)
			})

			Context("when the service instance is not user-provided and requires route forwarding", func() {
				BeforeEach(func() {
					serviceInstance := models.ServiceInstance{
						ServiceOffering: models.ServiceOfferingFields{
							Requires: []string{"route_forwarding"},
						},
					}
					serviceInstance.ServicePlan = models.ServicePlanFields{
						Guid: "service-plan-guid",
					}
					serviceInstanceRequirement.GetServiceInstanceReturns(serviceInstance)
				})