Example #1
0
func (BOSH) DirectorExists(address, username, password string) bool {
	client := bosh.NewClient(address, username, password)

	_, err := client.Info()
	return err == nil
}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Client", func() {
	Describe("Info", func() {
		It("returns the director info", func() {
			fakeBOSH := httptest.NewTLSServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
				responseWriter.Write([]byte(`{
					"name": "some-bosh-director",
					"uuid": "some-uuid",
					"version": "some-version"
				}`))
			}))

			client := bosh.NewClient(fakeBOSH.URL, "some-username", "some-password")
			info, err := client.Info()
			Expect(err).NotTo(HaveOccurred())
			Expect(info).To(Equal(bosh.Info{
				Name:    "some-bosh-director",
				UUID:    "some-uuid",
				Version: "some-version",
			}))
		})

		Context("failure cases", func() {
			It("returns an error when the response is not StatusOK", func() {
				fakeBOSH := httptest.NewTLSServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
					responseWriter.WriteHeader(http.StatusNotFound)
				}))