mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
chore: add more tests (#2409)
This commit is contained in:
parent
9138056c01
commit
5061158bd6
@ -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) {
|
||||
}
|
||||
|
20
gateway/internal/eventhandler_test.go
Normal file
20
gateway/internal/eventhandler_test.go
Normal file
@ -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…
Reference in New Issue
Block a user