-
Notifications
You must be signed in to change notification settings - Fork 4
/
service-use_test.go
49 lines (38 loc) · 1.12 KB
/
service-use_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
package main
import (
"errors"
"github.com/cdelashmutt-pivotal/service-use/apihelper"
"github.com/cdelashmutt-pivotal/service-use/apihelper/fakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("ServiceUse", func() {
var fakeAPI *fakes.FakeCFAPIHelper
var cmd *ServiceUsePlugin
BeforeEach(func() {
fakeAPI = &fakes.FakeCFAPIHelper{}
cmd = &ServiceUsePlugin{apiHelper: fakeAPI}
})
Describe("Get services composes the values correctly", func() {
service := apihelper.Service{
URL: "/v2/services/1234",
Label: "FakeService",
ServicePlansURL: "/v2/services/1234/serviceplans",
}
BeforeEach(func() {
fakeAPI.GetServicesReturns([]apihelper.Service{service}, nil)
})
It("should return a service", func() {
services, err := cmd.getServices()
Expect(err).To(BeNil())
Expect(len(services)).To(Equal(1))
})
})
Describe("API Call Errors", func() {
It("should return an error if /v2/organization call fails", func() {
fakeAPI.GetServicesReturns(nil, errors.New("BOOM"))
_, err := cmd.getServices()
Expect(err).ToNot(BeNil())
})
})
})