1 Star 0 Fork 0

铁匠/luchen

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
client_http_test.go 804 Bytes
一键复制 编辑 原始数据 按行查看 历史
package luchen_test
import (
"context"
"net/http"
"testing"
"github.com/fengjx/go-halo/json"
"github.com/fengjx/luchen"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
)
func TestHTTPClient_Call(t *testing.T) {
serviceName := "hello-test-http-call"
registrar := luchen.NewEtcdV3Registrar(
newHelloHttpServer(serviceName, ":0"),
)
registrar.Register()
defer registrar.Deregister()
client := luchen.GetHTTPClient(serviceName)
body, _ := json.ToBytes(&pb.HelloRequest{
Name: "fengjx",
})
req := &luchen.HTTPRequest{
Path: "/say-hello",
Method: http.MethodPost,
Body: body,
}
response, err := client.Call(context.Background(), req)
if err != nil {
t.Fatal(err)
}
if !response.IsSuccess() {
t.Fatal("http call not success")
}
t.Log(response.String())
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/fengjx/luchen.git
git@gitee.com:fengjx/luchen.git
fengjx
luchen
luchen
master

搜索帮助