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

refactor: rm apache thrift in internal/mocks #1474

Merged
merged 2 commits into from
Aug 2, 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
28 changes: 3 additions & 25 deletions client/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@

package client

import (
thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache"
)

// MockTStruct implements the thrift.TStruct interface.
type MockTStruct struct {
WriteFunc func(p thrift.TProtocol) (e error)
ReadFunc func(p thrift.TProtocol) (e error)
}

// Write implements the thrift.TStruct interface.
func (m MockTStruct) Write(p thrift.TProtocol) (e error) {
if m.WriteFunc != nil {
return m.WriteFunc(p)
}
return
}

// Read implements the thrift.TStruct interface.
func (m MockTStruct) Read(p thrift.TProtocol) (e error) {
if m.ReadFunc != nil {
return m.ReadFunc(p)
}
return
}
// MockTStruct was implemented the thrift.TStruct interface.
// But actually Read/Write are not in use, so removed... only empty struct left for testing
type MockTStruct struct{}
32 changes: 11 additions & 21 deletions internal/mocks/serviceinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"errors"
"fmt"

"github.com/apache/thrift/lib/go/thrift"
"github.com/cloudwego/gopkg/protocol/thrift"

"github.com/cloudwego/kitex/pkg/serviceinfo"
)
Expand Down Expand Up @@ -195,13 +195,9 @@ type myServiceMockArgs struct {
Req *MyRequest `thrift:"req,1" json:"req"`
}

func (p *myServiceMockArgs) Read(iprot thrift.TProtocol) error {
return nil
}

func (p *myServiceMockArgs) Write(oprot thrift.TProtocol) error {
return nil
}
func (p *myServiceMockArgs) BLength() int { return 1 }
func (p *myServiceMockArgs) FastWriteNocopy(buf []byte, bw thrift.NocopyWriter) int { return 1 }
func (p *myServiceMockArgs) FastRead(buf []byte) (int, error) { return 1, nil }

// MyRequest .
type MyRequest struct {
Expand All @@ -212,13 +208,9 @@ type myServiceMockResult struct {
Success *MyResponse `thrift:"success,0" json:"success,omitempty"`
}

func (p *myServiceMockResult) Read(iprot thrift.TProtocol) error {
return nil
}

func (p *myServiceMockResult) Write(oprot thrift.TProtocol) error {
return nil
}
func (p *myServiceMockResult) BLength() int { return 1 }
func (p *myServiceMockResult) FastWriteNocopy(buf []byte, bw thrift.NocopyWriter) int { return 1 }
func (p *myServiceMockResult) FastRead(buf []byte) (int, error) { return 1, nil }

// MyResponse .
type MyResponse struct {
Expand All @@ -230,13 +222,11 @@ type myServiceMockExceptionResult struct {
MyException *MyException `thrift:"stException,1" json:"stException,omitempty"`
}

func (p *myServiceMockExceptionResult) Read(iprot thrift.TProtocol) error {
return nil
}

func (p *myServiceMockExceptionResult) Write(oprot thrift.TProtocol) error {
return nil
func (p *myServiceMockExceptionResult) BLength() int { return 1 }
func (p *myServiceMockExceptionResult) FastWriteNocopy(buf []byte, bw thrift.NocopyWriter) int {
return 1
}
func (p *myServiceMockExceptionResult) FastRead(buf []byte) (int, error) { return 1, nil }

// MyException .
type MyException struct {
Expand Down
Loading
Loading