1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-02-13 13:48:51 +02:00
kratos/transport/http/binding/proto_test.go
Tony Chen 1b13abd136
transport/http: add http route (#1029)
* add http route

* fix http context

* add HTTP middleware

Co-authored-by: longXboy <longxboyhi@gmail.com>
2021-06-12 18:30:17 +08:00

33 lines
1.1 KiB
Go

package binding
import (
"fmt"
"testing"
)
func TestProtoPath(t *testing.T) {
url := EncodeVars("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name}", &HelloRequest{Name: "test", Sub: &Sub{Name: "2233!!!"}}, false)
fmt.Println(url)
if url != `http://helloworld.Greeter/helloworld/test/sub/2233!!!` {
t.Fatalf("proto path not expected!actual: %s ", url)
}
url = EncodeVars("http://helloworld.Greeter/helloworld/sub", &HelloRequest{Name: "test", Sub: &Sub{Name: "2233!!!"}}, false)
fmt.Println(url)
if url != `http://helloworld.Greeter/helloworld/sub` {
t.Fatalf("proto path not expected!actual: %s ", url)
}
url = EncodeVars("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name}", &HelloRequest{Name: "test"}, false)
fmt.Println(url)
if url != `http://helloworld.Greeter/helloworld/test/sub/` {
t.Fatalf("proto path not expected!actual: %s ", url)
}
url = EncodeVars("http://helloworld.Greeter/helloworld/{name}/sub/{sub.name33}", &HelloRequest{Name: "test"}, false)
fmt.Println(url)
if url != `http://helloworld.Greeter/helloworld/test/sub/{sub.name33}` {
t.Fatalf("proto path not expected!actual: %s ", url)
}
}