forked from cloudfoundry/brokerapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse_test.go
71 lines (58 loc) · 1.79 KB
/
response_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package brokerapi_test
import (
"encoding/json"
"github.com/pivotal-cf/brokerapi"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Catalog Response", func() {
Describe("JSON encoding", func() {
It("has a list of services", func() {
catalogResponse := brokerapi.CatalogResponse{
Services: []brokerapi.Service{},
}
jsonString := `{"services":[]}`
Expect(json.Marshal(catalogResponse)).To(MatchJSON(jsonString))
})
})
})
var _ = Describe("Provisioning Response", func() {
Describe("JSON encoding", func() {
Context("when the dashboard URL is not present", func() {
It("does not return it in the JSON", func() {
provisioningResponse := brokerapi.ProvisioningResponse{}
jsonString := `{}`
Expect(json.Marshal(provisioningResponse)).To(MatchJSON(jsonString))
})
})
Context("when the dashboard URL is present", func() {
It("returns it in the JSON", func() {
provisioningResponse := brokerapi.ProvisioningResponse{
DashboardURL: "http://example.com/broker",
}
jsonString := `{"dashboard_url":"http://example.com/broker"}`
Expect(json.Marshal(provisioningResponse)).To(MatchJSON(jsonString))
})
})
})
})
var _ = Describe("Binding Response", func() {
Describe("JSON encoding", func() {
It("has a credentials object", func() {
binding := brokerapi.Binding{}
jsonString := `{"credentials":null}`
Expect(json.Marshal(binding)).To(MatchJSON(jsonString))
})
})
})
var _ = Describe("Error Response", func() {
Describe("JSON encoding", func() {
It("has a description field", func() {
errorResponse := brokerapi.ErrorResponse{
Description: "a bad thing happened",
}
jsonString := `{"description":"a bad thing happened"}`
Expect(json.Marshal(errorResponse)).To(MatchJSON(jsonString))
})
})
})