From 88a4c1641dfb671d515d756870df27c81ebc6ab4 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 24 Jan 2022 22:44:26 +0300 Subject: [PATCH] reformat Signed-off-by: Vasiliy Tolstov --- api/handler/rpc/rpc_test.go | 3 -- broker/broker_test.go | 3 +- broker/segmentio/broker_test.go | 9 ++++-- client/client_call_options_test.go | 3 +- client/drpc/drpc_test.go | 2 +- client/drpc/proto/test.pb.go | 18 +++++++---- client/drpc/proto/test_drpc.pb.go | 1 + client/drpc/proto/test_micro.pb.go | 1 + client/drpc/proto/test_micro_rpc.pb.go | 1 + client/grpc/gproto/test_micro.pb.go | 1 + client/grpc/gproto/test_micro_rpc.pb.go | 1 + client/grpc/proto/test.pb.go | 18 +++++++---- client/grpc/proto/test_grpc.pb.go | 5 +-- client/http/http_test.go | 2 +- client/http/proto/github.pb.go | 20 +++++++----- client/http/proto/github_micro.pb.go | 1 + client/http/proto/github_micro_http.pb.go | 3 +- codec/frame_test.go | 24 ++++++++++++++ codec/proto/test.pb.go | 4 ++- codec/proto/test_micro.pb.go | 1 + codec/proto/test_micro_http.pb.go | 1 + codec/segmentio/generate.go | 1 - codec/segmentio/proto/test.pb.go | 18 +++++++---- codec/segmentio/proto/test_micro.pb.go | 1 + codec/segmentio/proto/test_micro_http.pb.go | 1 + flow/flow_test.go | 3 +- flow/proto/test.pb.go | 32 +++++++++++-------- flow/proto/test_micro.pb.go | 1 + flow/proto/test_micro_http.pb.go | 5 +-- go.mod | 8 ++--- go.sum | 8 ++--- meter/prometheus/prometheus_test.go | 2 +- meter/victoriametrics/victoriametrics_test.go | 2 +- protoc-gen-go-micro/proto/test_micro.pb.go | 1 + .../proto/test_micro_http.pb.go | 3 +- server/grpc/gproto/test_micro.pb.go | 1 + server/grpc/gproto/test_micro_rpc.pb.go | 1 + server/grpc/proto/test.pb.go | 20 +++++++----- server/grpc/proto/test_grpc.pb.go | 4 +-- server/http/http_test.go | 28 +++++++--------- server/http/proto/test.pb.go | 28 +++++++++------- server/http/proto/test_micro.pb.go | 1 + server/http/proto/test_micro_http.pb.go | 5 +-- store/store_test.go | 9 ++---- tools.go | 5 +-- util/reflect/proto/test.pb.go | 20 +++++++----- util/reflect/reflect_test.go | 6 ++-- wrapper/ratelimiter/juju/ratelimit_test.go | 1 + 48 files changed, 200 insertions(+), 137 deletions(-) create mode 100644 codec/frame_test.go diff --git a/api/handler/rpc/rpc_test.go b/api/handler/rpc/rpc_test.go index 52d32a6..b278bea 100644 --- a/api/handler/rpc/rpc_test.go +++ b/api/handler/rpc/rpc_test.go @@ -9,7 +9,6 @@ import ( ) func TestRequestPayloadFromRequest(t *testing.T) { - jsonUrlBytes := []byte(`{"key1":"val1","key2":"val2","name":"Test"}`) t.Run("extracting a json from a POST request with url params", func(t *testing.T) { @@ -58,7 +57,6 @@ func TestRequestPayloadFromRequest(t *testing.T) { }) t.Run("extracting params from a GET request", func(t *testing.T) { - r, err := http.NewRequest("GET", "http://localhost/my/path", nil) if err != nil { t.Fatalf("Failed to created http.Request: %v", err) @@ -78,7 +76,6 @@ func TestRequestPayloadFromRequest(t *testing.T) { }) t.Run("GET request with no params", func(t *testing.T) { - r, err := http.NewRequest("GET", "http://localhost/my/path", nil) if err != nil { t.Fatalf("Failed to created http.Request: %v", err) diff --git a/broker/broker_test.go b/broker/broker_test.go index 9144078..1785ca7 100644 --- a/broker/broker_test.go +++ b/broker/broker_test.go @@ -55,7 +55,8 @@ func TestOptionPassing(t *testing.T) { func TestKgo(t *testing.T) { if tr := os.Getenv("INTEGRATION_TESTS"); len(tr) > 0 { - t.Skip() + return + // t.Skip() } _ = logger.DefaultLogger.Init(logger.WithLevel(logger.TraceLevel), logger.WithCallerSkipCount(3)) diff --git a/broker/segmentio/broker_test.go b/broker/segmentio/broker_test.go index 668ffe0..276c704 100644 --- a/broker/segmentio/broker_test.go +++ b/broker/segmentio/broker_test.go @@ -38,7 +38,8 @@ var bm = &broker.Message{ func TestConsumerGroup(t *testing.T) { topic := "test_topic" if tr := os.Getenv("INTEGRATION_TESTS"); len(tr) > 0 { - t.Skip() + return + // t.Skip() } if err := logger.DefaultLogger.Init(logger.WithLevel(logger.TraceLevel)); err != nil { @@ -197,7 +198,8 @@ func TestConsumerGroup(t *testing.T) { func TestSub(t *testing.T) { topic := "test_topic" if tr := os.Getenv("INTEGRATION_TESTS"); len(tr) > 0 { - t.Skip() + return + // t.Skip() } if err := logger.DefaultLogger.Init(logger.WithLevel(logger.ErrorLevel)); err != nil { @@ -508,7 +510,8 @@ func BenchmarkPubSub(b *testing.B) { func TestPubSub(t *testing.T) { if tr := os.Getenv("INTEGRATION_TESTS"); len(tr) > 0 { - t.Skip() + return + // t.Skip() } if err := logger.DefaultLogger.Init(logger.WithLevel(logger.ErrorLevel)); err != nil { diff --git a/client/client_call_options_test.go b/client/client_call_options_test.go index a2b9c16..f2bf72d 100644 --- a/client/client_call_options_test.go +++ b/client/client_call_options_test.go @@ -19,8 +19,7 @@ import ( cw "go.unistack.org/micro/v3/util/client" ) -type TestFoo struct { -} +type TestFoo struct{} type TestReq struct{} diff --git a/client/drpc/drpc_test.go b/client/drpc/drpc_test.go index 8c24f11..235484a 100644 --- a/client/drpc/drpc_test.go +++ b/client/drpc/drpc_test.go @@ -1,8 +1,8 @@ // +build ignore -/* package drpc +/* import ( "context" "net" diff --git a/client/drpc/proto/test.pb.go b/client/drpc/proto/test.pb.go index feb9ae9..3123968 100644 --- a/client/drpc/proto/test.pb.go +++ b/client/drpc/proto/test.pb.go @@ -7,10 +7,11 @@ package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -146,11 +147,14 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_test_proto_goTypes = []interface{}{ - (*CallReq)(nil), // 0: Test.CallReq - (*CallRsp)(nil), // 1: Test.CallRsp -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) + file_test_proto_goTypes = []interface{}{ + (*CallReq)(nil), // 0: Test.CallReq + (*CallRsp)(nil), // 1: Test.CallRsp + } +) + var file_test_proto_depIdxs = []int32{ 0, // 0: Test.TestService.Call:input_type -> Test.CallReq 0, // 1: Test.TestService.Hello:input_type -> Test.CallReq diff --git a/client/drpc/proto/test_drpc.pb.go b/client/drpc/proto/test_drpc.pb.go index 4925d29..15faa19 100644 --- a/client/drpc/proto/test_drpc.pb.go +++ b/client/drpc/proto/test_drpc.pb.go @@ -7,6 +7,7 @@ package pb import ( context "context" errors "errors" + proto "google.golang.org/protobuf/proto" drpc "storj.io/drpc" drpcerr "storj.io/drpc/drpcerr" diff --git a/client/drpc/proto/test_micro.pb.go b/client/drpc/proto/test_micro.pb.go index 64d1c57..61e7d9f 100644 --- a/client/drpc/proto/test_micro.pb.go +++ b/client/drpc/proto/test_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" ) diff --git a/client/drpc/proto/test_micro_rpc.pb.go b/client/drpc/proto/test_micro_rpc.pb.go index 3866d04..2554d79 100644 --- a/client/drpc/proto/test_micro_rpc.pb.go +++ b/client/drpc/proto/test_micro_rpc.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v3/server" diff --git a/client/grpc/gproto/test_micro.pb.go b/client/grpc/gproto/test_micro.pb.go index 49c0e32..735b740 100644 --- a/client/grpc/gproto/test_micro.pb.go +++ b/client/grpc/gproto/test_micro.pb.go @@ -6,6 +6,7 @@ package helloworld import ( context "context" + proto "go.unistack.org/micro-tests/client/grpc/proto" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" diff --git a/client/grpc/gproto/test_micro_rpc.pb.go b/client/grpc/gproto/test_micro_rpc.pb.go index 0eb10c7..bb12265 100644 --- a/client/grpc/gproto/test_micro_rpc.pb.go +++ b/client/grpc/gproto/test_micro_rpc.pb.go @@ -6,6 +6,7 @@ package helloworld import ( context "context" + proto "go.unistack.org/micro-tests/client/grpc/proto" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" diff --git a/client/grpc/proto/test.pb.go b/client/grpc/proto/test.pb.go index 3ec7e06..880d320 100644 --- a/client/grpc/proto/test.pb.go +++ b/client/grpc/proto/test.pb.go @@ -7,10 +7,11 @@ package helloworld import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -158,11 +159,14 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_test_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: helloworld.Request - (*Response)(nil), // 1: helloworld.Response -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) + file_test_proto_goTypes = []interface{}{ + (*Request)(nil), // 0: helloworld.Request + (*Response)(nil), // 1: helloworld.Response + } +) + var file_test_proto_depIdxs = []int32{ 0, // 0: helloworld.Test.Call:input_type -> helloworld.Request 0, // 1: helloworld.Test.Stream:input_type -> helloworld.Request diff --git a/client/grpc/proto/test_grpc.pb.go b/client/grpc/proto/test_grpc.pb.go index 80a8872..02068cd 100644 --- a/client/grpc/proto/test_grpc.pb.go +++ b/client/grpc/proto/test_grpc.pb.go @@ -8,6 +8,7 @@ package helloworld import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -84,12 +85,12 @@ type TestServer interface { } // UnimplementedTestServer must be embedded to have forward compatible implementations. -type UnimplementedTestServer struct { -} +type UnimplementedTestServer struct{} func (UnimplementedTestServer) Call(context.Context, *Request) (*Response, error) { return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") } + func (UnimplementedTestServer) Stream(Test_StreamServer) error { return status.Errorf(codes.Unimplemented, "method Stream not implemented") } diff --git a/client/http/http_test.go b/client/http/http_test.go index e97178b..df133d0 100644 --- a/client/http/http_test.go +++ b/client/http/http_test.go @@ -244,7 +244,7 @@ func TestHTTPClientStream(t *testing.T) { // write response rsp := &http.Response{ - Header: r.Header, + // Header: r.Header, Body: ioutil.NopCloser(bytes.NewBuffer(b)), Status: "200 OK", StatusCode: 200, diff --git a/client/http/proto/github.pb.go b/client/http/proto/github.pb.go index 9bbcd7a..d92009f 100644 --- a/client/http/proto/github.pb.go +++ b/client/http/proto/github.pb.go @@ -7,12 +7,13 @@ package pb import ( + reflect "reflect" + sync "sync" + _ "go.unistack.org/micro-proto/v3/api" _ "go.unistack.org/micro-proto/v3/openapiv3" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( @@ -225,12 +226,15 @@ func file_github_proto_rawDescGZIP() []byte { return file_github_proto_rawDescData } -var file_github_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_github_proto_goTypes = []interface{}{ - (*LookupUserReq)(nil), // 0: github.LookupUserReq - (*LookupUserRsp)(nil), // 1: github.LookupUserRsp - (*Error)(nil), // 2: github.Error -} +var ( + file_github_proto_msgTypes = make([]protoimpl.MessageInfo, 3) + file_github_proto_goTypes = []interface{}{ + (*LookupUserReq)(nil), // 0: github.LookupUserReq + (*LookupUserRsp)(nil), // 1: github.LookupUserRsp + (*Error)(nil), // 2: github.Error + } +) + var file_github_proto_depIdxs = []int32{ 0, // 0: github.Github.LookupUser:input_type -> github.LookupUserReq 0, // 1: github.Github.LookupUserWithoutPath:input_type -> github.LookupUserReq diff --git a/client/http/proto/github_micro.pb.go b/client/http/proto/github_micro.pb.go index f3de394..fe19d9a 100644 --- a/client/http/proto/github_micro.pb.go +++ b/client/http/proto/github_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" ) diff --git a/client/http/proto/github_micro_http.pb.go b/client/http/proto/github_micro_http.pb.go index ed915e9..59bba74 100644 --- a/client/http/proto/github_micro_http.pb.go +++ b/client/http/proto/github_micro_http.pb.go @@ -6,11 +6,12 @@ package pb import ( context "context" + http "net/http" + v3 "go.unistack.org/micro-client-http/v3" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v3/server" - http "net/http" ) type githubClient struct { diff --git a/codec/frame_test.go b/codec/frame_test.go new file mode 100644 index 0000000..1759092 --- /dev/null +++ b/codec/frame_test.go @@ -0,0 +1,24 @@ +package codec + +import ( + "fmt" + "testing" + + jsoncodec "go.unistack.org/micro-codec-json/v3" + "go.unistack.org/micro/v3/codec" +) + +func TestFrame(t *testing.T) { + type FrameStruct struct { + Frame *codec.Frame `json:"frame"` + Name string `json:"name"` + } + dst := &FrameStruct{} + data := []byte(`{"name":"test","frame": {"first":"second"}}`) + c := jsoncodec.NewCodec() + + if err := c.Unmarshal(data, dst); err != nil { + t.Fatal(err) + } + fmt.Printf("xxx %s\n", dst.Frame) +} diff --git a/codec/proto/test.pb.go b/codec/proto/test.pb.go index a8fceeb..cbd3617 100644 --- a/codec/proto/test.pb.go +++ b/codec/proto/test.pb.go @@ -7,10 +7,11 @@ package pb import ( + reflect "reflect" + codec "go.unistack.org/micro/v3/codec" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" ) const ( @@ -38,6 +39,7 @@ var file_test_proto_rawDesc = []byte{ var file_test_proto_goTypes = []interface{}{ (*codec.Frame)(nil), // 0: micro.codec.Frame } + var file_test_proto_depIdxs = []int32{ 0, // 0: helloworld.Test.Call:input_type -> micro.codec.Frame 0, // 1: helloworld.Test.Call:output_type -> micro.codec.Frame diff --git a/codec/proto/test_micro.pb.go b/codec/proto/test_micro.pb.go index 73536c4..ef78b5c 100644 --- a/codec/proto/test_micro.pb.go +++ b/codec/proto/test_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" codec "go.unistack.org/micro/v3/codec" diff --git a/codec/proto/test_micro_http.pb.go b/codec/proto/test_micro_http.pb.go index 15e8350..94455aa 100644 --- a/codec/proto/test_micro_http.pb.go +++ b/codec/proto/test_micro_http.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + _ "go.unistack.org/micro-client-http/v3" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" diff --git a/codec/segmentio/generate.go b/codec/segmentio/generate.go index 64ef86a..c50f7e4 100644 --- a/codec/segmentio/generate.go +++ b/codec/segmentio/generate.go @@ -1,4 +1,3 @@ package grpc //go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto --go-micro_out=components='micro|http',debug=true,paths=source_relative:./proto proto/test.proto" - diff --git a/codec/segmentio/proto/test.pb.go b/codec/segmentio/proto/test.pb.go index c1dc4ef..573bc3e 100644 --- a/codec/segmentio/proto/test.pb.go +++ b/codec/segmentio/proto/test.pb.go @@ -7,10 +7,11 @@ package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -154,11 +155,14 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_test_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: helloworld.Request - (*Response)(nil), // 1: helloworld.Response -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) + file_test_proto_goTypes = []interface{}{ + (*Request)(nil), // 0: helloworld.Request + (*Response)(nil), // 1: helloworld.Response + } +) + var file_test_proto_depIdxs = []int32{ 0, // 0: helloworld.Test.Call:input_type -> helloworld.Request 1, // 1: helloworld.Test.Call:output_type -> helloworld.Response diff --git a/codec/segmentio/proto/test_micro.pb.go b/codec/segmentio/proto/test_micro.pb.go index dba20c9..4a00633 100644 --- a/codec/segmentio/proto/test_micro.pb.go +++ b/codec/segmentio/proto/test_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" ) diff --git a/codec/segmentio/proto/test_micro_http.pb.go b/codec/segmentio/proto/test_micro_http.pb.go index a335999..6f4ccb7 100644 --- a/codec/segmentio/proto/test_micro_http.pb.go +++ b/codec/segmentio/proto/test_micro_http.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + _ "go.unistack.org/micro-client-http/v3" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" diff --git a/flow/flow_test.go b/flow/flow_test.go index 93aaa17..6933496 100644 --- a/flow/flow_test.go +++ b/flow/flow_test.go @@ -138,5 +138,6 @@ func TestFlow(t *testing.T) { t.Fatal(err) } _ = keys - t.Logf("execution id: %s, result: %v", id, err) + _ = id + // t.Logf("execution id: %s, result: %v", id, err) } diff --git a/flow/proto/test.pb.go b/flow/proto/test.pb.go index 2853a19..b83e67d 100644 --- a/flow/proto/test.pb.go +++ b/flow/proto/test.pb.go @@ -7,12 +7,13 @@ package pb import ( + reflect "reflect" + sync "sync" + _ "go.unistack.org/micro-proto/v3/api" _ "go.unistack.org/micro-proto/v3/openapiv3" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( @@ -503,18 +504,21 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_test_proto_goTypes = []interface{}{ - (*MailUserReq)(nil), // 0: test.MailUserReq - (*MailUserRsp)(nil), // 1: test.MailUserRsp - (*UpdateUserReq)(nil), // 2: test.UpdateUserReq - (*UpdateUserRsp)(nil), // 3: test.UpdateUserRsp - (*DeleteUserReq)(nil), // 4: test.DeleteUserReq - (*DeleteUserRsp)(nil), // 5: test.DeleteUserRsp - (*LookupUserReq)(nil), // 6: test.LookupUserReq - (*LookupUserRsp)(nil), // 7: test.LookupUserRsp - (*Error)(nil), // 8: test.Error -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 9) + file_test_proto_goTypes = []interface{}{ + (*MailUserReq)(nil), // 0: test.MailUserReq + (*MailUserRsp)(nil), // 1: test.MailUserRsp + (*UpdateUserReq)(nil), // 2: test.UpdateUserReq + (*UpdateUserRsp)(nil), // 3: test.UpdateUserRsp + (*DeleteUserReq)(nil), // 4: test.DeleteUserReq + (*DeleteUserRsp)(nil), // 5: test.DeleteUserRsp + (*LookupUserReq)(nil), // 6: test.LookupUserReq + (*LookupUserRsp)(nil), // 7: test.LookupUserRsp + (*Error)(nil), // 8: test.Error + } +) + var file_test_proto_depIdxs = []int32{ 6, // 0: test.TestService.LookupUser:input_type -> test.LookupUserReq 2, // 1: test.TestService.UpdateUser:input_type -> test.UpdateUserReq diff --git a/flow/proto/test_micro.pb.go b/flow/proto/test_micro.pb.go index 17bf334..098ceab 100644 --- a/flow/proto/test_micro.pb.go +++ b/flow/proto/test_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" ) diff --git a/flow/proto/test_micro_http.pb.go b/flow/proto/test_micro_http.pb.go index f1660b7..522a1ad 100644 --- a/flow/proto/test_micro_http.pb.go +++ b/flow/proto/test_micro_http.pb.go @@ -6,12 +6,13 @@ package pb import ( context "context" + http "net/http" + time "time" + v3 "go.unistack.org/micro-client-http/v3" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v3/server" - http "net/http" - time "time" ) type testServiceClient struct { diff --git a/go.mod b/go.mod index 1906000..f0b474d 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,6 @@ module go.unistack.org/micro-tests go 1.16 -//replace go.unistack.org/micro/v3 => ../micro - -//replace go.unistack.org/micro-wrapper-sql/v3 => ../micro-wrapper-sql - require ( github.com/jmoiron/sqlx v1.3.4 github.com/opentracing/opentracing-go v1.2.0 @@ -31,7 +27,7 @@ require ( go.unistack.org/micro-proto/v3 v3.2.0 go.unistack.org/micro-router-register/v3 v3.8.1 go.unistack.org/micro-server-grpc/v3 v3.8.0 - go.unistack.org/micro-server-http/v3 v3.9.2 + go.unistack.org/micro-server-http/v3 v3.9.3 go.unistack.org/micro-server-tcp/v3 v3.8.0 go.unistack.org/micro-wrapper-recovery/v3 v3.8.0 go.unistack.org/micro-wrapper-sql/v3 v3.0.1 @@ -43,5 +39,5 @@ require ( google.golang.org/grpc v1.43.0 google.golang.org/protobuf v1.27.1 modernc.org/sqlite v1.14.5 - storj.io/drpc v0.0.26 + storj.io/drpc v0.0.27 ) diff --git a/go.sum b/go.sum index c10093a..f39fc2e 100644 --- a/go.sum +++ b/go.sum @@ -433,8 +433,8 @@ go.unistack.org/micro-router-register/v3 v3.8.1 h1:7pxbBxT4gk9XfigpHYWHFEljWpwVX go.unistack.org/micro-router-register/v3 v3.8.1/go.mod h1:JKRDKYMl6A/ZqIux2D4txgerRfT+HJdPbo0Ik6nKo98= go.unistack.org/micro-server-grpc/v3 v3.8.0 h1:/cP4WBftiO7Vlj9D5YUShqmnw7CxyobXZCVshs5YfY8= go.unistack.org/micro-server-grpc/v3 v3.8.0/go.mod h1:UcevUkT7vZwDVxWWHWg+GtSDG6ro5doNxihNKdDCr1o= -go.unistack.org/micro-server-http/v3 v3.9.2 h1:i7gzWomYF+on5EcqTVwiTrhBH0zccI8LeHFku0BZrEc= -go.unistack.org/micro-server-http/v3 v3.9.2/go.mod h1:yLssWbsrlN9/uGkHvwuzhW5hTdjcDOlyBiOcMMKf67k= +go.unistack.org/micro-server-http/v3 v3.9.3 h1:oc+ZUzoF7gZ4CZ1v4RIr0cjdHWOLaKC0f/bJ/BYphWQ= +go.unistack.org/micro-server-http/v3 v3.9.3/go.mod h1:yLssWbsrlN9/uGkHvwuzhW5hTdjcDOlyBiOcMMKf67k= go.unistack.org/micro-server-tcp/v3 v3.8.0 h1:J6vuctWx/A4FRrY4FuS5KUGPopLEpB8/2c8ntWQfWXk= go.unistack.org/micro-server-tcp/v3 v3.8.0/go.mod h1:U2LjBk52yxq6QyOmZomS2FJTqca6E0q71UJrW4QgoNk= go.unistack.org/micro-wrapper-recovery/v3 v3.8.0 h1:ivobT81NUA/74hshbbXM7iOcgODYDHvD2JOHVas6qxU= @@ -758,5 +758,5 @@ modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.2.21/go.mod h1:uXrObx4pGqXWIMliC5MiKuwAyMrltzwpteOFUP1PWCc= modernc.org/z v1.3.0 h1:4RWULo1Nvaq5ZBhbLe74u8p6tV4Mmm0ZrPBXYPm/xjM= modernc.org/z v1.3.0/go.mod h1:+mvgLH814oDjtATDdT3rs84JnUIpkvAF5B8AVkNlE2g= -storj.io/drpc v0.0.26 h1:T6jJzjby7QUa/2XHR1qMxTCENpDHEw4/o+kfDfZQqQI= -storj.io/drpc v0.0.26/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko= +storj.io/drpc v0.0.27 h1:5XDCuciLfSUAizxWW9d29MQKuwBTX1G6+kp60LgzHWA= +storj.io/drpc v0.0.27/go.mod h1:6rcOyR/QQkSTX/9L5ZGtlZaE2PtXTTZl8d+ulSeeYEg= diff --git a/meter/prometheus/prometheus_test.go b/meter/prometheus/prometheus_test.go index 5ea2e32..8d864ac 100644 --- a/meter/prometheus/prometheus_test.go +++ b/meter/prometheus/prometheus_test.go @@ -5,11 +5,11 @@ import ( "context" "testing" + prometheus "go.unistack.org/micro-meter-prometheus/v3" "go.unistack.org/micro/v3/client" "go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/meter" "go.unistack.org/micro/v3/meter/wrapper" - prometheus "go.unistack.org/micro-meter-prometheus/v3" ) func TestWrapper(t *testing.T) { diff --git a/meter/victoriametrics/victoriametrics_test.go b/meter/victoriametrics/victoriametrics_test.go index 0608c9f..7cbbddd 100644 --- a/meter/victoriametrics/victoriametrics_test.go +++ b/meter/victoriametrics/victoriametrics_test.go @@ -5,11 +5,11 @@ import ( "context" "testing" + victoriametrics "go.unistack.org/micro-meter-victoriametrics/v3" "go.unistack.org/micro/v3/client" "go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/meter" "go.unistack.org/micro/v3/meter/wrapper" - victoriametrics "go.unistack.org/micro-meter-victoriametrics/v3" ) func TestWrapper(t *testing.T) { diff --git a/protoc-gen-go-micro/proto/test_micro.pb.go b/protoc-gen-go-micro/proto/test_micro.pb.go index 2c5ed73..75fefe5 100644 --- a/protoc-gen-go-micro/proto/test_micro.pb.go +++ b/protoc-gen-go-micro/proto/test_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" codec "go.unistack.org/micro/v3/codec" diff --git a/protoc-gen-go-micro/proto/test_micro_http.pb.go b/protoc-gen-go-micro/proto/test_micro_http.pb.go index 341dd1d..0377358 100644 --- a/protoc-gen-go-micro/proto/test_micro_http.pb.go +++ b/protoc-gen-go-micro/proto/test_micro_http.pb.go @@ -6,13 +6,14 @@ package pb import ( context "context" + http "net/http" + v3 "go.unistack.org/micro-client-http/v3" v31 "go.unistack.org/micro-server-http/v3" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" codec "go.unistack.org/micro/v3/codec" server "go.unistack.org/micro/v3/server" - http "net/http" ) type testServiceClient struct { diff --git a/server/grpc/gproto/test_micro.pb.go b/server/grpc/gproto/test_micro.pb.go index d985134..7423051 100644 --- a/server/grpc/gproto/test_micro.pb.go +++ b/server/grpc/gproto/test_micro.pb.go @@ -6,6 +6,7 @@ package helloworld import ( context "context" + proto "go.unistack.org/micro-tests/server/grpc/proto" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" diff --git a/server/grpc/gproto/test_micro_rpc.pb.go b/server/grpc/gproto/test_micro_rpc.pb.go index 995c8e7..1b957a4 100644 --- a/server/grpc/gproto/test_micro_rpc.pb.go +++ b/server/grpc/gproto/test_micro_rpc.pb.go @@ -6,6 +6,7 @@ package helloworld import ( context "context" + proto "go.unistack.org/micro-tests/server/grpc/proto" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" diff --git a/server/grpc/proto/test.pb.go b/server/grpc/proto/test.pb.go index f426a44..ca9ecd2 100644 --- a/server/grpc/proto/test.pb.go +++ b/server/grpc/proto/test.pb.go @@ -7,11 +7,12 @@ package helloworld import ( + reflect "reflect" + sync "sync" + _ "go.unistack.org/micro-proto/v3/api" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( @@ -229,12 +230,15 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_test_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: helloworld.Request - (*Broken)(nil), // 1: helloworld.Broken - (*Response)(nil), // 2: helloworld.Response -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3) + file_test_proto_goTypes = []interface{}{ + (*Request)(nil), // 0: helloworld.Request + (*Broken)(nil), // 1: helloworld.Broken + (*Response)(nil), // 2: helloworld.Response + } +) + var file_test_proto_depIdxs = []int32{ 1, // 0: helloworld.Request.broken:type_name -> helloworld.Broken 1, // 1: helloworld.Response.broken:type_name -> helloworld.Broken diff --git a/server/grpc/proto/test_grpc.pb.go b/server/grpc/proto/test_grpc.pb.go index 0bb51e6..ec0cbb8 100644 --- a/server/grpc/proto/test_grpc.pb.go +++ b/server/grpc/proto/test_grpc.pb.go @@ -8,6 +8,7 @@ package helloworld import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -51,8 +52,7 @@ type TestServer interface { } // UnimplementedTestServer must be embedded to have forward compatible implementations. -type UnimplementedTestServer struct { -} +type UnimplementedTestServer struct{} func (UnimplementedTestServer) Call(context.Context, *Request) (*Response, error) { return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") diff --git a/server/http/http_test.go b/server/http/http_test.go index 08d4ac8..40f08a9 100644 --- a/server/http/http_test.go +++ b/server/http/http_test.go @@ -94,7 +94,7 @@ func TestMultipart(t *testing.T) { server.Register(reg), server.Codec("application/json", jsoncodec.NewCodec()), server.Codec("application/x-www-form-urlencoded", urlencodecodec.NewCodec()), - httpsrv.PathHandler("/upload", multipartHandler), + httpsrv.PathHandler(http.MethodPost, "/upload", multipartHandler), ) if err := srv.Init(); err != nil { @@ -125,7 +125,7 @@ func TestMultipart(t *testing.T) { t.Fatalf("Expected 1 node got %d: %+v", len(service[0].Nodes), service[0].Nodes) } - t.Logf("test multipart upload") + // t.Logf("test multipart upload") values := make(map[string]io.Reader, 2) values["first.txt"] = bytes.NewReader([]byte("first content")) values["second.txt"] = bytes.NewReader([]byte("second content")) @@ -261,7 +261,6 @@ func TestNativeFormUrlencoded(t *testing.T) { t.Fatalf("Expected 1 node got %d: %+v", len(service[0].Nodes), service[0].Nodes) } - t.Logf("test net/http client with application/x-www-form-urlencoded") data := url.Values{} data.Set("req", "fookey") data.Set("arg1", "arg1val") @@ -275,12 +274,12 @@ func TestNativeFormUrlencoded(t *testing.T) { req.AddCookie(&http.Cookie{Name: "Csrftoken", Value: "csrftoken"}) // req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode()))) if err != nil { - t.Fatal(err) + t.Fatalf("test net/http client with application/x-www-form-urlencoded err: %v", err) } rsp, err := http.DefaultClient.Do(req) if err != nil { - t.Fatal(err) + t.Fatalf("test net/http client with application/x-www-form-urlencoded err: %v", err) } b, err := ioutil.ReadAll(rsp.Body) @@ -302,7 +301,6 @@ func TestNativeFormUrlencoded(t *testing.T) { t.Fatalf("empty response header: %#+v", rsp.Header) } - t.Logf("test native client with application/x-www-form-urlencoded") cli := client.NewClientCallOptions( httpcli.NewClient( client.ContentType("application/x-www-form-urlencoded"), @@ -324,7 +322,7 @@ func TestNativeFormUrlencoded(t *testing.T) { }}, }) if err != nil { - t.Fatal(err) + t.Fatalf("test native client with application/x-www-form-urlencoded err: %v", err) } if nrsp.Rsp != "name_my_name" { @@ -438,16 +436,15 @@ func TestNativeClientServer(t *testing.T) { t.Fatal(err) } - t.Logf("test rsp code from net/http client to native micro http server") hr, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("http://%s/v1/test/call/my_name", service[0].Nodes[0].Address), bytes.NewReader(hb)) if err != nil { - t.Fatal(err) + t.Fatalf("test rsp code from net/http client to native micro http server err: %v", err) } hr.Header.Set("Content-Type", "application/json") hrsp, err := http.DefaultClient.Do(hr) if err != nil { - t.Fatal(err) + t.Fatalf("test rsp code from net/http client to native micro http server err: %v", err) } defer func() { _ = hrsp.Body.Close() @@ -462,17 +459,16 @@ func TestNativeClientServer(t *testing.T) { t.Fatalf("invalid rsp code %#+v", hrsp) } - t.Logf("test second server") svc2 := pb.NewTestDoubleClient("helloworld", cli) rsp, err = svc2.CallDouble(ctx, &pb.CallReq{ Name: "my_name", }) if err != nil { - t.Fatal(err) + t.Fatalf("test second server err: %v", err) } if rsp.Rsp != "name_double" { - t.Fatalf("invalid response: %#+v\n", rsp) + t.Fatalf("test second server invalid response: %#+v\n", rsp) } hrsp, err = http.Get(fmt.Sprintf("http://%s/metrics", service[0].Nodes[0].Address)) @@ -610,20 +606,18 @@ func TestNativeServer(t *testing.T) { c := client.NewClientCallOptions(httpcli.NewClient(client.ContentType("application/json"), client.Codec("application/json", jsoncodec.NewCodec())), client.WithAddress("http://"+service[0].Nodes[0].Address)) pbc := pb.NewTestClient("test", c) - t.Logf("test with string_ids") prsp, err := pbc.CallRepeatedString(context.TODO(), &pb.CallReq{StringIds: []string{"123", "321"}}) if err != nil { - t.Fatal(err) + t.Fatalf("test with string_ids err: %v", err) } if prsp.Rsp != "name_my_name" { t.Fatalf("invalid rsp received: %#+v\n", rsp) } - t.Logf("test with int64_ids") prsp, err = pbc.CallRepeatedInt64(context.TODO(), &pb.CallReq{Int64Ids: []int64{123, 321}}) if err != nil { - t.Fatal(err) + t.Fatalf("test with int64_ids err: %v", err) } if prsp.Rsp != "name_my_name" { diff --git a/server/http/proto/test.pb.go b/server/http/proto/test.pb.go index a2b932b..7d8f6fa 100644 --- a/server/http/proto/test.pb.go +++ b/server/http/proto/test.pb.go @@ -7,14 +7,15 @@ package pb import ( + reflect "reflect" + sync "sync" + _ "go.unistack.org/micro-proto/v3/api" _ "go.unistack.org/micro-proto/v3/openapiv3" _ "go.unistack.org/micro-proto/v3/tag" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" - reflect "reflect" - sync "sync" ) const ( @@ -493,16 +494,19 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_test_proto_goTypes = []interface{}{ - (*CallReq)(nil), // 0: test.CallReq - (*Nested)(nil), // 1: test.Nested - (*CallRsp)(nil), // 2: test.CallRsp - (*CallReq1)(nil), // 3: test.CallReq1 - (*CallRsp1)(nil), // 4: test.CallRsp1 - (*Error)(nil), // 5: test.Error - (*wrapperspb.UInt64Value)(nil), // 6: google.protobuf.UInt64Value -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 6) + file_test_proto_goTypes = []interface{}{ + (*CallReq)(nil), // 0: test.CallReq + (*Nested)(nil), // 1: test.Nested + (*CallRsp)(nil), // 2: test.CallRsp + (*CallReq1)(nil), // 3: test.CallReq1 + (*CallRsp1)(nil), // 4: test.CallRsp1 + (*Error)(nil), // 5: test.Error + (*wrapperspb.UInt64Value)(nil), // 6: google.protobuf.UInt64Value + } +) + var file_test_proto_depIdxs = []int32{ 1, // 0: test.CallReq.nested:type_name -> test.Nested 6, // 1: test.Nested.uint64_args:type_name -> google.protobuf.UInt64Value diff --git a/server/http/proto/test_micro.pb.go b/server/http/proto/test_micro.pb.go index 8652bbb..03c0214 100644 --- a/server/http/proto/test_micro.pb.go +++ b/server/http/proto/test_micro.pb.go @@ -6,6 +6,7 @@ package pb import ( context "context" + api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" ) diff --git a/server/http/proto/test_micro_http.pb.go b/server/http/proto/test_micro_http.pb.go index 75a9819..606d253 100644 --- a/server/http/proto/test_micro_http.pb.go +++ b/server/http/proto/test_micro_http.pb.go @@ -6,13 +6,14 @@ package pb import ( context "context" + http "net/http" + time "time" + v3 "go.unistack.org/micro-client-http/v3" v31 "go.unistack.org/micro-server-http/v3" api "go.unistack.org/micro/v3/api" client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v3/server" - http "net/http" - time "time" ) type testDoubleClient struct { diff --git a/store/store_test.go b/store/store_test.go index 021014c..07a92f6 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -95,7 +95,6 @@ func TestStoreBasic(t *testing.T) { runStoreTest(tc.s, t) }) } - } func TestStoreTable(t *testing.T) { @@ -176,7 +175,6 @@ func runStoreTest(s store.Store, t *testing.T) { suffixPrefixExpiryTests(s, t) readTests(s, t) listTests(s, t) - } func readTests(s store.Store, t *testing.T) { @@ -285,7 +283,6 @@ func listTests(s store.Store, t *testing.T) { if len(recs) != 2 { t.Fatalf("Expected 2 records, received %d %+v", len(recs), recs) } - } func expiryTests(s store.Store, t *testing.T) { @@ -457,9 +454,8 @@ func suffixPrefixExpiryTests(s store.Store, t *testing.T) { } else { if len(results) != 3 { t.Errorf("Expected 3 items, got %d", len(results)) - //t.Logf("Table test: %v\n", spew.Sdump(results)) + // t.Logf("Table test: %v\n", spew.Sdump(results)) } - } time.Sleep(time.Millisecond * 100) if results, err := s.Read("foo", store.ReadSuffix()); err != nil { @@ -467,9 +463,8 @@ func suffixPrefixExpiryTests(s store.Store, t *testing.T) { } else { if len(results) != 2 { t.Errorf("Expected 2 items, got %d", len(results)) - //t.Logf("Table test: %v\n", spew.Sdump(results)) + // t.Logf("Table test: %v\n", spew.Sdump(results)) } - } time.Sleep(time.Millisecond * 100) if results, err := s.Read("foo", store.ReadSuffix()); err != nil { diff --git a/tools.go b/tools.go index fff6f3a..331d25f 100644 --- a/tools.go +++ b/tools.go @@ -1,9 +1,10 @@ +//go:build tools // +build tools -package micro-tests +package micro_tests import ( - _ "go.unistack.org/micro-proto/v3/openapiv3" _ "go.unistack.org/micro-proto/v3/api" + _ "go.unistack.org/micro-proto/v3/openapiv3" _ "go.unistack.org/micro-proto/v3/tag" ) diff --git a/util/reflect/proto/test.pb.go b/util/reflect/proto/test.pb.go index bc9e0e5..51e32cf 100644 --- a/util/reflect/proto/test.pb.go +++ b/util/reflect/proto/test.pb.go @@ -7,11 +7,12 @@ package pb import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" - reflect "reflect" - sync "sync" ) const ( @@ -194,12 +195,15 @@ func file_test_proto_rawDescGZIP() []byte { return file_test_proto_rawDescData } -var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_test_proto_goTypes = []interface{}{ - (*CallReq)(nil), // 0: reflect.CallReq - (*Nested)(nil), // 1: reflect.Nested - (*wrapperspb.UInt64Value)(nil), // 2: google.protobuf.UInt64Value -} +var ( + file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) + file_test_proto_goTypes = []interface{}{ + (*CallReq)(nil), // 0: reflect.CallReq + (*Nested)(nil), // 1: reflect.Nested + (*wrapperspb.UInt64Value)(nil), // 2: google.protobuf.UInt64Value + } +) + var file_test_proto_depIdxs = []int32{ 1, // 0: reflect.CallReq.nested:type_name -> reflect.Nested 2, // 1: reflect.Nested.uint64_args:type_name -> google.protobuf.UInt64Value diff --git a/util/reflect/reflect_test.go b/util/reflect/reflect_test.go index 06326c3..90eaab7 100644 --- a/util/reflect/reflect_test.go +++ b/util/reflect/reflect_test.go @@ -61,9 +61,8 @@ func TestMergeString(t *testing.T) { mp["bool"] = true s := &str{} - t.Logf("merge with true") if err := rutil.Merge(s, mp, rutil.Tags([]string{"json"})); err != nil { - t.Fatal(err) + t.Fatalf("merge with true err: %v", err) } if s.Bool != "true" { @@ -71,9 +70,8 @@ func TestMergeString(t *testing.T) { } mp["bool"] = false - t.Logf("merge with false") if err := rutil.Merge(s, mp, rutil.Tags([]string{"json"})); err != nil { - t.Fatal(err) + t.Fatalf("merge with falst err: %v", err) } if s.Bool != "false" { diff --git a/wrapper/ratelimiter/juju/ratelimit_test.go b/wrapper/ratelimiter/juju/ratelimit_test.go index e768dbd..ba9bcd9 100644 --- a/wrapper/ratelimiter/juju/ratelimit_test.go +++ b/wrapper/ratelimiter/juju/ratelimit_test.go @@ -15,6 +15,7 @@ import ( "go.unistack.org/micro/v3/client" "go.unistack.org/micro/v3/errors" "go.unistack.org/micro/v3/network/transport" + "go.unistack.org/micro/v3/register" "go.unistack.org/micro/v3/router" "go.unistack.org/micro/v3/server" )