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.
30 lines
609 B
30 lines
609 B
3 years ago
|
package grpc
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/go-kratos/kratos/v2/selector/filter"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"google.golang.org/grpc/metadata"
|
||
|
)
|
||
|
|
||
|
func TestTrailer(t *testing.T) {
|
||
|
trailer := Trailer(metadata.New(map[string]string{"a": "b"}))
|
||
|
assert.Equal(t, "b", trailer.Get("a"))
|
||
|
assert.Equal(t, "", trailer.Get("3"))
|
||
|
}
|
||
|
|
||
|
func TestBalancerName(t *testing.T) {
|
||
|
o := &clientOptions{}
|
||
|
|
||
|
WithBalancerName("p2c")(o)
|
||
|
assert.Equal(t, "p2c", o.balancerName)
|
||
|
}
|
||
|
|
||
|
func TestFilters(t *testing.T) {
|
||
|
o := &clientOptions{}
|
||
|
|
||
|
WithSelectFilter(filter.Version("2"))(o)
|
||
|
assert.Equal(t, 1, len(o.filters))
|
||
|
}
|