1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-16 02:47:03 +02:00
kratos/transport/grpc/transport_test.go
Kagaya f7588a47de
fix: ci lint error (#1391)
* fix lint check

* fix lll lint error

* fix build error

* fix gomnd

* fix shadow declaration

* add make test command

* update
2021-08-31 10:14:57 +08:00

49 lines
1.0 KiB
Go

package grpc
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/go-kratos/kratos/v2/transport"
)
func TestTransport_Kind(t *testing.T) {
o := &Transport{}
assert.Equal(t, transport.KindGRPC, o.Kind())
}
func TestTransport_Endpoint(t *testing.T) {
v := "hello"
o := &Transport{endpoint: v}
assert.Equal(t, v, o.Endpoint())
}
func TestTransport_Operation(t *testing.T) {
v := "hello"
o := &Transport{operation: v}
assert.Equal(t, v, o.Operation())
}
func TestTransport_RequestHeader(t *testing.T) {
v := headerCarrier{}
v.Set("a", "1")
o := &Transport{reqHeader: v}
assert.Equal(t, "1", o.RequestHeader().Get("a"))
assert.Equal(t, "", o.RequestHeader().Get("notfound"))
}
func TestTransport_ReplyHeader(t *testing.T) {
v := headerCarrier{}
v.Set("a", "1")
o := &Transport{replyHeader: v}
assert.Equal(t, "1", o.ReplyHeader().Get("a"))
}
func TestHeaderCarrier_Keys(t *testing.T) {
v := headerCarrier{}
v.Set("abb", "1")
v.Set("bcc", "2")
assert.ElementsMatch(t, []string{"abb", "bcc"}, v.Keys())
}