You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/transport/grpc/balancer_test.go

32 lines
722 B

package grpc
import (
"context"
"reflect"
"testing"
"google.golang.org/grpc/metadata"
"github.com/go-kratos/kratos/v2/selector"
)
func TestTrailer(t *testing.T) {
trailer := Trailer(metadata.New(map[string]string{"a": "b"}))
if !reflect.DeepEqual("b", trailer.Get("a")) {
t.Errorf("expect %v, got %v", "b", trailer.Get("a"))
}
if !reflect.DeepEqual("", trailer.Get("notfound")) {
t.Errorf("expect %v, got %v", "", trailer.Get("notfound"))
}
}
func TestFilters(t *testing.T) {
o := &clientOptions{}
WithNodeFilter(func(_ context.Context, nodes []selector.Node) []selector.Node {
return nodes
})(o)
if !reflect.DeepEqual(1, len(o.filters)) {
t.Errorf("expect %v, got %v", 1, len(o.filters))
}
}