Esempio n. 1
0
			Expect(path).To(Equal("/path"))
			Expect(domain).To(Equal("domain-guid"))
			Expect(space).To(Equal("space-guid"))
		})

		It("does not add an extra forward slash when the path contains a prefixed forward slash", func() {
			cmd.Execute(flagContext)

			Expect(routeRepo.CreateInSpaceCallCount()).To(Equal(1))
			_, path, _, _ := routeRepo.CreateInSpaceArgsForCall(0)
			Expect(path).To(Equal("/path"))
		})

		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.FindByHostAndDomainCallCount()).To(Equal(1))
			})

			Context("when finding the route fails", func() {
				BeforeEach(func() {
					routeRepo.FindByHostAndDomainReturns(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"}))