chore: add more tests (#2409)

master
Kevin Wan 2 years ago committed by GitHub
parent 9138056c01
commit 5061158bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,15 +27,6 @@ func NewEventHandler(writer io.Writer, resolver jsonpb.AnyResolver) *EventHandle
}
}
func (h *EventHandler) OnResolveMethod(_ *desc.MethodDescriptor) {
}
func (h *EventHandler) OnSendHeaders(_ metadata.MD) {
}
func (h *EventHandler) OnReceiveHeaders(_ metadata.MD) {
}
func (h *EventHandler) OnReceiveResponse(message proto.Message) {
if err := h.marshaler.Marshal(h.writer, message); err != nil {
logx.Error(err)
@ -45,3 +36,12 @@ func (h *EventHandler) OnReceiveResponse(message proto.Message) {
func (h *EventHandler) OnReceiveTrailers(status *status.Status, _ metadata.MD) {
h.Status = status
}
func (h *EventHandler) OnResolveMethod(_ *desc.MethodDescriptor) {
}
func (h *EventHandler) OnSendHeaders(_ metadata.MD) {
}
func (h *EventHandler) OnReceiveHeaders(_ metadata.MD) {
}

@ -0,0 +1,20 @@
package internal
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func TestEventHandler(t *testing.T) {
h := NewEventHandler(io.Discard, nil)
h.OnResolveMethod(nil)
h.OnSendHeaders(nil)
h.OnReceiveHeaders(nil)
h.OnReceiveTrailers(status.New(codes.OK, ""), nil)
assert.Equal(t, codes.OK, h.Status.Code())
h.OnReceiveResponse(nil)
}
Loading…
Cancel
Save