mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 09:40:24 +08:00
8d567b5508
* chore: add more tests * feat: support customized header processor
22 lines
531 B
Go
22 lines
531 B
Go
package internal
|
|
|
|
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, ProcessHeaders(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.ElementsMatch(t, []string{"gateway-A:b", "gateway-B:b"}, ProcessHeaders(req.Header))
|
|
}
|