Esempio n. 1
0
File: client.go Progetto: Gerg/bbs
func (c *client) Domains() ([]string, error) {
	var domains models.Domains
	err := c.doRequest(DomainsRoute, nil, nil, nil, &domains)
	return domains.GetDomains(), err
}
Esempio n. 2
0
		Context("when reading domains from DB succeeds", func() {
			BeforeEach(func() {
				fakeDomainDB.GetAllDomainsReturns(&models.Domains{Domains: domains}, nil)
			})

			It("call the DB to retrieve the domains", func() {
				Expect(fakeDomainDB.GetAllDomainsCallCount()).To(Equal(1))
			})

			It("responds with 200 Status OK", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusOK))
			})

			It("returns a list of domains", func() {
				response := models.Domains{}
				err := response.Unmarshal(responseRecorder.Body.Bytes())
				Expect(err).NotTo(HaveOccurred())

				Expect(response.GetDomains()).To(ConsistOf(domains))
			})
		})

		Context("when the DB returns no domains", func() {
			BeforeEach(func() {
				fakeDomainDB.GetAllDomainsReturns(&models.Domains{}, nil)
			})

			It("responds with 200 Status OK", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusOK))
			})