Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rm unused base.TrafficEnv #73

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions conv/j2t/conv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,18 @@ const (
)

func TestCases(t *testing.T) {
var tests = []struct{
name string
idl string
var tests = []struct {
name string
idl string
includes map[string]string
js string
opt conv.Options
want interface{}
err error
js string
opt conv.Options
want interface{}
err error
}{
{
name: "int2double_vm",
idl:
`struct Req {
idl: `struct Req {
1: optional double body (api.js_conv=""),
}

Expand All @@ -101,16 +100,15 @@ service SVR {
}
`,
includes: nil,
js: `{"body":"-1"}`,
opt: conv.Options{},
js: `{"body":"-1"}`,
opt: conv.Options{},
want: map[string]interface{}{
"body": float64(-1),
},
},
{
name: "int2double",
idl:
`struct Req {
idl: `struct Req {
1: optional double body,
}

Expand All @@ -119,8 +117,8 @@ service SVR {
}
`,
includes: nil,
js: `{"body":-2}`,
opt: conv.Options{EnableValueMapping: true},
js: `{"body":-2}`,
opt: conv.Options{EnableValueMapping: true},
want: map[string]interface{}{
"body": float64(-2),
},
Expand Down Expand Up @@ -154,7 +152,6 @@ service SVR {
}
}


func TestConvJSON2Thrift(t *testing.T) {
desc := getExampleDesc()
data := getExampleData()
Expand Down Expand Up @@ -185,7 +182,7 @@ func TestPanicRecover(t *testing.T) {
ctx = context.WithValue(ctx, conv.CtxKeyHTTPRequest, req)
buf := make([]byte, 0, 1)
mock := MockConv{
panic:2,
panic: 2,
}
defer func() {
if v := recover(); v == nil {
Expand Down Expand Up @@ -746,11 +743,11 @@ func TestFloat2Int(t *testing.T) {
}

type MockConv struct {
sp int
reqsCache int
keyCache int
fieldCache int
panic int
sp int
reqsCache int
keyCache int
fieldCache int
panic int
}

func (mock *MockConv) Do(self *BinaryConv, ctx context.Context, desc *thrift.TypeDescriptor, jbytes []byte) (tbytes []byte, err error) {
Expand Down Expand Up @@ -819,7 +816,7 @@ func (mock MockConv) do(self *BinaryConv, ctx context.Context, src []byte, desc
}()

exec:
mock.panic -= 1
mock.panic -= 1
if mock.panic == 0 {
panic("test!")
}
Expand Down Expand Up @@ -885,10 +882,10 @@ func TestStateMachineOOM(t *testing.T) {
require.Nil(t, err)
exp.RawUri = req.GetUri()
mock := MockConv{
sp: 1,
reqsCache: 1,
keyCache: 1,
fieldCache: 0,
sp: 1,
reqsCache: 1,
keyCache: 1,
fieldCache: 0,
}
cv := NewBinaryConv(conv.Options{
EnableHttpMapping: true,
Expand Down Expand Up @@ -941,9 +938,6 @@ func TestThriftRequestBase(t *testing.T) {
b.Extra = map[string]string{
"key": "value",
}
b.TrafficEnv = &base.TrafficEnv{
Env: "env",
}
ctx = context.WithValue(ctx, conv.CtxKeyThriftReqBase, b)
app, err := json.Marshal(b)
require.NoError(t, err)
Expand Down
10 changes: 0 additions & 10 deletions thrift/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ import (
"github.com/cloudwego/gopkg/protocol/thrift/base"
)

// TrafficEnv ...
// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base
type TrafficEnv = base.TrafficEnv

// NewTrafficEnv ...
// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base
func NewTrafficEnv() *TrafficEnv {
return base.NewTrafficEnv()
}

// Base ...
// Deprecated: use github.com/cloudwego/gopkg/protocol/thrift/base
type Base = base.Base
Expand Down
Loading