2022-07-17 12:37:23 +08:00
|
|
|
package internal
|
2022-07-16 14:11:34 +08:00
|
|
|
|
|
|
|
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")
|
2022-07-17 12:37:23 +08:00
|
|
|
assert.Nil(t, BuildHeaders(req.Header))
|
2022-07-16 14:11:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildHeadersWithValues(t *testing.T) {
|
|
|
|
req := httptest.NewRequest("GET", "/", nil)
|
|
|
|
req.Header.Add("grpc-metadata-a", "b")
|
|
|
|
req.Header.Add("grpc-metadata-b", "b")
|
2022-07-17 12:37:23 +08:00
|
|
|
assert.EqualValues(t, []string{"gateway-A:b", "gateway-B:b"}, BuildHeaders(req.Header))
|
2022-07-16 14:11:34 +08:00
|
|
|
}
|