Esempio n. 1
0
				),
			)
		})

		AfterEach(func() {
			ccServer.Close()
		})

		It("tries to create the app", func() {
			repo.Create(appParams)
			Expect(ccServer.ReceivedRequests()).To(HaveLen(1))
		})

		Context("when the create succeeds", func() {
			BeforeEach(func() {
				h := ccServer.GetHandler(0)
				ccServer.SetHandler(0,
					ghttp.CombineHandlers(
						h,
						ghttp.RespondWith(http.StatusCreated, `{
							"metadata": {
									"guid": "my-cool-app-guid"
							},
							"entity": {
									"name": "my-cool-app"
							}
					}`),
					),
				)
			})
Esempio n. 2
0
				It("Should create 'get' command with proper name", func() {
					Expect(getCommand.Name).To(Equal("tower show"))
				})

				It("Should get resource successfully", func() {
					result, err := getCommand.Action([]string{icyTowerID})
					Expect(err).ToNot(HaveOccurred())
					var resultJSON interface{}
					json.Unmarshal([]byte(result), &resultJSON)
					Expect(resultJSON).To(Equal(getIcyTower()))
				})

				It("Should get resource by name successfully", func() {
					server.SetHandler(1, ghttp.RespondWith(404, nil))
					handler := server.GetHandler(2)
					server.SetHandler(2, ghttp.RespondWithJSONEncoded(200, getIcyTowerListResponse()))
					server.AppendHandlers(handler)
					result, err := getCommand.Action([]string{icyTowerName})
					Expect(err).ToNot(HaveOccurred())
					var resultJSON interface{}
					json.Unmarshal([]byte(result), &resultJSON)
					Expect(resultJSON).To(Equal(getIcyTower()))
				})

				It("Should show error - wrong number of arguments", func() {
					result, err := getCommand.Action([]string{})
					Expect(result).To(Equal(""))
					Expect(err).To(MatchError("Wrong number of arguments"))
				})