/
status.go
28 lines (24 loc) · 868 Bytes
/
status.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
package grpcmatchers
import (
"github.com/onsi/gomega/types"
"google.golang.org/grpc/status"
"github.com/jamillosantos/gomega-grpc/matchersimpl"
)
// HaveStatusCode will match the *status.Status Code property against the given matcher.
func HaveStatusCode(matcher types.GomegaMatcher) *matchersimpl.GRPCStatusMatcher {
return matchersimpl.NewGRPCStatusMatcher(&matchersimpl.GRPCStatusPropMatcher{
PropMap: func(st *status.Status) interface{} {
return st.Code()
},
Matcher: matcher,
})
}
// HaveStatusMessage will match the *status.Status Message property against the given matcher.
func HaveStatusMessage(matcher types.GomegaMatcher) *matchersimpl.GRPCStatusMatcher {
return matchersimpl.NewGRPCStatusMatcher(&matchersimpl.GRPCStatusPropMatcher{
PropMap: func(st *status.Status) interface{} {
return st.Message()
},
Matcher: matcher,
})
}