From 0b3005f71e2cafe9822900d9df9b6be259871a39 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 16 Dec 2020 00:00:31 +0300 Subject: [PATCH] add native http test case Signed-off-by: Vasiliy Tolstov --- client/http/http_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/http/http_test.go b/client/http/http_test.go index 0cf4290..334c48c 100644 --- a/client/http/http_test.go +++ b/client/http/http_test.go @@ -31,6 +31,24 @@ type Message struct { 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) { reg := rmemory.NewRegistry() rtr := rrouter.NewRouter(router.Registry(reg))