mirror of
https://github.com/hanzoai/grpc-web.git
synced 2026-10-30 18:35:37 +00:00
* Allow non root resources * code review * code review * code review * code review * add non root resource test * add non root resource test * add non root resource test * code review * code review
30 lines
918 B
Go
30 lines
918 B
Go
package grpcweb
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetGRPCEndpoint(t *testing.T) {
|
|
cases := []struct {
|
|
input string
|
|
output string
|
|
}{
|
|
{input: "/", output: "/"},
|
|
{input: "/resource", output: "/resource"},
|
|
{input: "/improbable.grpcweb.test.TestService/PingEmpty", output: "/improbable.grpcweb.test.TestService/PingEmpty"},
|
|
{input: "/improbable.grpcweb.test.TestService/PingEmpty/", output: "/improbable.grpcweb.test.TestService/PingEmpty"},
|
|
{input: "/a/b/c/improbable.grpcweb.test.TestService/PingEmpty", output: "/improbable.grpcweb.test.TestService/PingEmpty"},
|
|
{input: "/a/b/c/improbable.grpcweb.test.TestService/PingEmpty/", output: "/improbable.grpcweb.test.TestService/PingEmpty"},
|
|
}
|
|
|
|
for _, c := range cases {
|
|
req := httptest.NewRequest("GET", c.input, nil)
|
|
result := getGRPCEndpoint(req)
|
|
|
|
assert.Equal(t, c.output, result)
|
|
}
|
|
}
|