mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
22 lines
524 B
Go
22 lines
524 B
Go
|
package gateway
|
||
|
|
||
|
import (
|
||
|
"net/http/httptest"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestBuildHeadersNoValue(t *testing.T) {
|
||
|
req := httptest.NewRequest("GET", "/", nil)
|
||
|
req.Header.Add("a", "b")
|
||
|
assert.Nil(t, buildHeaders(req.Header))
|
||
|
}
|
||
|
|
||
|
func TestBuildHeadersWithValues(t *testing.T) {
|
||
|
req := httptest.NewRequest("GET", "/", nil)
|
||
|
req.Header.Add("grpc-metadata-a", "b")
|
||
|
req.Header.Add("grpc-metadata-b", "b")
|
||
|
assert.EqualValues(t, []string{"gateway-A:b", "gateway-B:b"}, buildHeaders(req.Header))
|
||
|
}
|