add native http test case
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
d2e120478f
commit
0b3005f71e
@ -31,6 +31,24 @@ type Message struct {
|
|||||||
Data string
|
Data string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GithubRsp struct {
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNative(t *testing.T) {
|
||||||
|
c := client.NewClientCallOptions(mhttp.NewClient(client.ContentType("application/json"), client.Codec("application/json", jsoncodec.NewCodec())), client.WithAddress("https://api.github.com"))
|
||||||
|
req := c.NewRequest("github", "/users/vtolstov", nil)
|
||||||
|
rsp := &GithubRsp{}
|
||||||
|
err := c.Call(context.TODO(), req, rsp, mhttp.Method(http.MethodGet))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if rsp.Name != "Vasiliy Tolstov" {
|
||||||
|
t.Fatalf("invlid rsp received: %#+v\n", rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestHTTPClient(t *testing.T) {
|
func TestHTTPClient(t *testing.T) {
|
||||||
reg := rmemory.NewRegistry()
|
reg := rmemory.NewRegistry()
|
||||||
rtr := rrouter.NewRouter(router.Registry(reg))
|
rtr := rrouter.NewRouter(router.Registry(reg))
|
||||||
|
Loading…
Reference in New Issue
Block a user