-
Notifications
You must be signed in to change notification settings - Fork 20
/
assertions.go
48 lines (42 loc) · 1.22 KB
/
assertions.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
package integration
import (
//. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func assertSucceeds(request string) {
response, err := execCPI(request)
Expect(err).ToNot(HaveOccurred())
Expect(response.Error).To(BeNil())
}
func assertFails(request string) error {
response, err := execCPI(request)
Expect(err).To(HaveOccurred())
Expect(response.Error).ToNot(BeNil())
return response.Error
}
func assertSucceedsWithResult(request string) interface{} {
response, err := execCPI(request)
Expect(err).ToNot(HaveOccurred())
Expect(response.Error).To(BeNil())
Expect(response.Result).ToNot(BeNil())
return response.Result
}
func assertSucceedsWithResultOrCatchCapacityError(request string) interface{} {
response, err := execCPI(request)
Expect(err).ToNot(HaveOccurred())
if response.Error != nil {
Expect(response.Error.Error()).To(ContainSubstring("There is insufficient capacity to complete the request."))
Expect(response.Error).To(BeNil())
return response.Result
} else {
Expect(response.Result).ToNot(BeNil())
return response.Result
}
}
func toStringArray(raw []interface{}) []string {
strings := make([]string, len(raw), len(raw))
for i := range raw {
strings[i] = raw[i].(string)
}
return strings
}