コード例 #1
0
ファイル: cell_handlers_test.go プロジェクト: timani/bbs
						Containers: 20,
					},
				},
			}
			cellSet = models.NewCellSet()
			cellSet.Add(cells[0])
			cellSet.Add(cells[1])
		})

		JustBeforeEach(func() {
			handler.Cells(responseRecorder, newTestRequest(""))
		})

		Context("when reading cells succeeds", func() {
			BeforeEach(func() {
				fakeServiceClient.CellsReturns(cellSet, nil)
			})

			It("returns a list of cells", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusOK))

				response := &models.CellsResponse{}
				err := response.Unmarshal(responseRecorder.Body.Bytes())
				Expect(err).NotTo(HaveOccurred())

				Expect(response.Error).To(BeNil())
				Expect(response.Cells).To(ConsistOf(cells))
			})
		})

		Context("when the serviceClient returns no cells", func() {
コード例 #2
0
		repClientFactory.CreateClientReturns(repClient)
		logger = lagertest.NewTestLogger("delegate")

		delegate = auctionrunnerdelegate.New(repClientFactory, bbsClient, serviceClient, logger)
	})

	Describe("fetching cell reps", func() {
		Context("when the BSS succeeds", func() {
			BeforeEach(func() {
				cellPresence1 := models.NewCellPresence("cell-A", "cell-a.url", "zone-1", models.NewCellCapacity(123, 456, 789), []string{}, []string{})
				cellPresence2 := models.NewCellPresence("cell-B", "cell-b.url", "zone-1", models.NewCellCapacity(123, 456, 789), []string{}, []string{})
				cellSet := models.NewCellSet()
				cellSet.Add(&cellPresence1)
				cellSet.Add(&cellPresence2)

				serviceClient.CellsReturns(cellSet, nil)
			})

			It("creates rep clients with the correct addresses", func() {
				_, err := delegate.FetchCellReps()
				Expect(err).NotTo(HaveOccurred())
				Expect(repClientFactory.CreateClientCallCount()).To(Equal(2))
				urls := []string{
					repClientFactory.CreateClientArgsForCall(0),
					repClientFactory.CreateClientArgsForCall(1),
				}
				Expect(urls).To(ConsistOf("cell-a.url", "cell-b.url"))
			})

			It("returns correctly configured auction_http_clients", func() {
				reps, err := delegate.FetchCellReps()