Skip to content

Commit

Permalink
feat: remove unused modules
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Jun 28, 2023
1 parent e821b25 commit f5e8300
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 97 deletions.
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ require (
github.com/iancoleman/strcase v0.2.0
github.com/klauspost/cpuid/v2 v2.2.4
github.com/stretchr/testify v1.8.2
github.com/thrift-iterator/go v0.0.0-20190402154806-9b5a67519118
github.com/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631 // indirect
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6 // indirect
github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2 // indirect
)
15 changes: 0 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhD
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/iasm v0.0.0-20220818063314-28c361dae733/go.mod h1:wOQ0nsbeOLa2awv8bUYFW/EHXbjQMlZ10fAlXDB2sz8=
github.com/choleraehyq/pid v0.0.13/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U=
github.com/choleraehyq/pid v0.0.15 h1:PejhUZowqxxssjwyaw4OZURRFjnvftZfeEWK9UoWPXU=
github.com/choleraehyq/pid v0.0.15/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U=
github.com/choleraehyq/pid v0.0.16 h1:1/714sMH9IBlE/aK6xM0acTagGKSzpiR0bDt7l0cG7o=
github.com/choleraehyq/pid v0.0.16/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U=
Expand Down Expand Up @@ -78,7 +77,6 @@ github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHL
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand All @@ -96,41 +94,30 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso=
github.com/oleiade/lane v1.0.1/go.mod h1:IyTkraa4maLfjq/GmHR+Dxb4kCMtEGeb+qmhlrQ5Mk4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/thrift-iterator/go v0.0.0-20190402154806-9b5a67519118 h1:MIx5ElxAmfKzHGb3ptBbq9YE3weh55cH1Mb7VA4Oxbg=
github.com/thrift-iterator/go v0.0.0-20190402154806-9b5a67519118/go.mod h1:60PRwE/TCI1UqLvn8v2pwAf6+yzTPLP/Ji5xaesWDqk=
github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631 h1:WYq/4UeJfAorBY7ncC31bVxI031x4MUCQvF+z12fIYA=
github.com/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631/go.mod h1:3gacX+hQo+xvl0vtLqCMufzxuNCwt4geAVOMt2LQYfE=
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6 h1:hb7P11ytAQIcQ7Cq1uQBNTGgKQle7N+jsP4L72ooa7Q=
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6/go.mod h1:0VP5W9AFNVWU8C1QLNeVg8TvzoEkIHWZ4vxtxEVFWUY=
github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2 h1:g9qBO/hKkIHxSkyt0/I7R51pFxzVO1tNIUEwhV2yJ28=
github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2/go.mod h1:wen8nMxrRrUmXnRwH+3wGAW+hyYTHcOrTNhMpxyp/i0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -248,9 +235,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
92 changes: 92 additions & 0 deletions testdata/binary_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Copyright 2023 CloudWeGo Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package testdata

import (
"bytes"
"encoding/hex"
"reflect"
"testing"

"github.com/cloudwego/dynamicgo/meta"
"github.com/cloudwego/dynamicgo/thrift"
thrift_iter "github.com/thrift-iterator/go"
"github.com/thrift-iterator/go/general"
"github.com/thrift-iterator/go/protocol"
)

func TestBinaryUnwrapReply(t *testing.T) {

type args struct {
proto meta.Encoding
msg general.Message
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "simple",
args: args{
proto: meta.EncodingThriftBinary,
msg: general.Message{
MessageHeader: protocol.MessageHeader{
MessageName: "GetFavoriteMethod",
MessageType: protocol.MessageTypeReply,
},
Arguments: general.Struct{
1: general.Struct{
1: int32(7749),
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// pair of buffer
inputBytes, err := thrift_iter.Marshal(tt.args.msg)
if err != nil {
t.Fatalf("failed to marshal input %s", err)
}
wantBytes, err := thrift_iter.Marshal(tt.args.msg.Arguments[1].(general.Struct))
if err != nil {
t.Fatalf("failed to marshal want bytes %s", err)
}
//
_, _, _, _, got, err := thrift.UnwrapBinaryMessage(inputBytes)
if (err != nil) != tt.wantErr {
t.Errorf("UnwrapReply() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, wantBytes) {
t.Errorf("UnwrapReply() = %s, want %s", hex.EncodeToString(got), hex.EncodeToString(wantBytes))
}
header, footer, err := thrift.GetBinaryMessageHeaderAndFooter(tt.args.msg.MessageHeader.MessageName, thrift.TMessageType(tt.args.msg.MessageHeader.MessageType), 1, 0)
if err != nil {
t.Fatalf("failed to wrap message %s", err)
}
header = append(header, got...)
header = append(header, footer...)
if !bytes.Equal(header, inputBytes) {
t.Errorf("WrapBinaryMessage() = %s, want %s", hex.EncodeToString(header), hex.EncodeToString(inputBytes))
}

})
}
}
7 changes: 4 additions & 3 deletions conv/j2t/http_conv_test.go → testdata/h2t_conv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
* limitations under the License.
*/

package j2t
package testdata

import (
"context"
"testing"

"github.com/cloudwego/dynamicgo/conv"
"github.com/cloudwego/dynamicgo/conv/j2t"
"github.com/cloudwego/dynamicgo/http"
"github.com/cloudwego/dynamicgo/internal/util_test"
"github.com/cloudwego/dynamicgo/meta"
Expand All @@ -44,7 +45,7 @@ func getFnDescByPathName(t *testing.T, filePath, fnName string) *thrift.Function
return fn
}

func TestHTTPConv_Do(t *testing.T) {
func TestHTTP2ThriftConv_Do(t *testing.T) {
t.Parallel()
getFavoriteFn := getFnDescByPathName(t, "testdata/idl/example4.thrift", "GetFavoriteMethod")

Expand Down Expand Up @@ -107,7 +108,7 @@ func TestHTTPConv_Do(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
convIns := NewHTTPConv(tt.proto, tt.fn)
convIns := j2t.NewHTTPConv(tt.proto, tt.fn)
gotTbytes := make([]byte, 0, 1)
err := convIns.DoInto(context.Background(), tt.req, &gotTbytes, conv.Options{
WriteRequireField: true,
Expand Down
9 changes: 5 additions & 4 deletions conv/t2j/http_conv_test.go → testdata/t2h_conv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
* limitations under the License.
*/

package t2j
package testdata

import (
"context"
"testing"

"github.com/cloudwego/dynamicgo/conv"
"github.com/cloudwego/dynamicgo/conv/t2j"
"github.com/cloudwego/dynamicgo/internal/util_test"
"github.com/cloudwego/dynamicgo/meta"
"github.com/cloudwego/dynamicgo/thrift"
"github.com/stretchr/testify/assert"
)

func TestHTTPConv_Do(t *testing.T) {
func TestThrift2HTTPConv_Do(t *testing.T) {
svc, err := thrift.NewDescritorFromPath(context.Background(), util_test.MustGitPath("testdata/idl/example4.thrift"))
if err != nil {
t.Fatal(err)
Expand All @@ -39,14 +40,14 @@ func TestHTTPConv_Do(t *testing.T) {

tests := []struct {
name string
conv *HTTPConv
conv *t2j.HTTPConv
tbytes []byte
wantErr bool
want util_test.Resp
}{
{
name: "example4",
conv: NewHTTPConv(meta.EncodingThriftBinary, fn),
conv: t2j.NewHTTPConv(meta.EncodingThriftBinary, fn),
tbytes: util_test.MustDecodeHex(
t,
"80010002000000114765744661766f726974654d6574686f64000000130c00000c000108000100001e450f00020b00000002"+
Expand Down
71 changes: 0 additions & 71 deletions thrift/binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@
package thrift

import (
"bytes"
"context"
"encoding/hex"
"io/ioutil"
"os"
"reflect"
"runtime"
"runtime/debug"
"testing"
"time"

"github.com/cloudwego/dynamicgo/meta"
thrift_iter "github.com/thrift-iterator/go"
"github.com/thrift-iterator/go/general"
"github.com/thrift-iterator/go/protocol"
)

var (
Expand Down Expand Up @@ -67,67 +59,4 @@ func getExampleData() []byte {
panic(err)
}
return out
}

func TestBinaryUnwrapReply(t *testing.T) {

type args struct {
proto meta.Encoding
msg general.Message
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "simple",
args: args{
proto: meta.EncodingThriftBinary,
msg: general.Message{
MessageHeader: protocol.MessageHeader{
MessageName: "GetFavoriteMethod",
MessageType: protocol.MessageTypeReply,
},
Arguments: general.Struct{
1: general.Struct{
1: int32(7749),
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// pair of buffer
inputBytes, err := thrift_iter.Marshal(tt.args.msg)
if err != nil {
t.Fatalf("failed to marshal input %s", err)
}
wantBytes, err := thrift_iter.Marshal(tt.args.msg.Arguments[1].(general.Struct))
if err != nil {
t.Fatalf("failed to marshal want bytes %s", err)
}
//
_, _, _, _, got, err := UnwrapBinaryMessage(inputBytes)
if (err != nil) != tt.wantErr {
t.Errorf("UnwrapReply() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, wantBytes) {
t.Errorf("UnwrapReply() = %s, want %s", hex.EncodeToString(got), hex.EncodeToString(wantBytes))
}
header, footer, err := GetBinaryMessageHeaderAndFooter(tt.args.msg.MessageHeader.MessageName, TMessageType(tt.args.msg.MessageHeader.MessageType), 1, 0)
if err != nil {
t.Fatalf("failed to wrap message %s", err)
}
header = append(header, got...)
header = append(header, footer...)
if !bytes.Equal(header, inputBytes) {
t.Errorf("WrapBinaryMessage() = %s, want %s", hex.EncodeToString(header), hex.EncodeToString(inputBytes))
}

})
}
}

0 comments on commit f5e8300

Please sign in to comment.