Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
57
pkg/grpc/sms/smsmock.go
Normal file
57
pkg/grpc/sms/smsmock.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package sms
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type SMSSendHandlerFunc func(ctx context.Context, in *SendSMSRequest, opts ...grpc.CallOption) (*SMSDetailsResponse, error)
|
||||
|
||||
func NewSMSMock(handler SMSSendHandlerFunc) SMSMock {
|
||||
return SMSMock{
|
||||
SMSSendHandler: handler,
|
||||
}
|
||||
}
|
||||
|
||||
func NewSMSMockSuccess() SMSMock {
|
||||
return SMSMock{
|
||||
SMSSendHandler: func(ctx context.Context, in *SendSMSRequest, opts ...grpc.CallOption) (*SMSDetailsResponse, error) {
|
||||
return nil, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type SMSMock struct {
|
||||
SMSSendHandler SMSSendHandlerFunc
|
||||
UnimplementedSMSServiceServer
|
||||
queueResponse *SMSQueueResponse
|
||||
queueResponseError error
|
||||
}
|
||||
|
||||
func (m *SMSMock) HandleSMSSend(ctx context.Context, in *SendSMSRequest, opts ...grpc.CallOption) (*SMSDetailsResponse, error) {
|
||||
return m.SMSSendHandler(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// HandleSMSQueue implements sms.SMSServiceClient.
|
||||
func (m *SMSMock) HandleSMSQueue(ctx context.Context, in *SendSMSRequest, opts ...grpc.CallOption) (*SMSQueueResponse, error) {
|
||||
return m.queueResponse, m.queueResponseError
|
||||
}
|
||||
|
||||
func (m *SMSMock) SetHandleSMSQueueResponse(response *SMSQueueResponse, err error) {
|
||||
m.queueResponse = response
|
||||
m.queueResponseError = err
|
||||
}
|
||||
|
||||
func (m *SMSMock) HandleGetProducts(ctx context.Context, in *GetAvailableProductsRequest, opts ...grpc.CallOption) (*GetAvailableProductsResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *SMSMock) HandleChangeRatePlan(ctx context.Context, in *ChangeRatePlanRequest, opts ...grpc.CallOption) (*ChangeRatePlanResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *SMSMock) HandleCustomAttributes(ctx context.Context, in *CustomAtributesRequest, opts ...grpc.CallOption) (*CustomAtributeResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *SMSMock) HandleDeviceDetails(ctx context.Context, in *DeviceDetailsRequest, opts ...grpc.CallOption) (*DeviceDetailsResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user