diff --git a/internal/testutil/mocks/servicemock.go b/internal/testutil/mocks/servicemock.go deleted file mode 100644 index 9033376..0000000 --- a/internal/testutil/mocks/servicemock.go +++ /dev/null @@ -1,54 +0,0 @@ -package mocks - -import ( - "context" - - "git.grassecon.net/grassrootseconomics/visedriver/models" - dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api" - "github.com/stretchr/testify/mock" -) - -// MockAccountService implements AccountServiceInterface for testing -type MockAccountService struct { - mock.Mock -} - -func (m *MockAccountService) CreateAccount(ctx context.Context) (*models.AccountResult, error) { - args := m.Called() - return args.Get(0).(*models.AccountResult), args.Error(1) -} - -func (m *MockAccountService) CheckBalance(ctx context.Context, publicKey string) (*models.BalanceResult, error) { - args := m.Called(publicKey) - return args.Get(0).(*models.BalanceResult), args.Error(1) -} - -func (m *MockAccountService) TrackAccountStatus(ctx context.Context, trackingId string) (*models.TrackStatusResult, error) { - args := m.Called(trackingId) - return args.Get(0).(*models.TrackStatusResult), args.Error(1) -} - -func (m *MockAccountService) FetchVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) { - args := m.Called(publicKey) - return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1) -} - -func (m *MockAccountService) FetchTransactions(ctx context.Context, publicKey string) ([]dataserviceapi.Last10TxResponse, error) { - args := m.Called(publicKey) - return args.Get(0).([]dataserviceapi.Last10TxResponse), args.Error(1) -} - -func (m *MockAccountService) VoucherData(ctx context.Context, address string) (*models.VoucherDataResult, error) { - args := m.Called(address) - return args.Get(0).(*models.VoucherDataResult), args.Error(1) -} - -func (m *MockAccountService) TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error) { - args := m.Called() - return args.Get(0).(*models.TokenTransferResponse), args.Error(1) -} - -func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) { - args := m.Called(alias) - return args.Get(0).(*dataserviceapi.AliasAddress), args.Error(1) -} diff --git a/models/accountresponse.go b/models/account_response.go similarity index 100% rename from models/accountresponse.go rename to models/account_response.go diff --git a/models/balanceresponse.go b/models/balance_response.go similarity index 100% rename from models/balanceresponse.go rename to models/balance_response.go diff --git a/models/trackstatusresponse.go b/models/track_status_response.go similarity index 100% rename from models/trackstatusresponse.go rename to models/track_status_response.go diff --git a/remote/accountservice.go b/remote/account_service.go similarity index 100% rename from remote/accountservice.go rename to remote/account_service.go diff --git a/storage/storageservice.go b/storage/storage_service.go similarity index 100% rename from storage/storageservice.go rename to storage/storage_service.go diff --git a/testutil/mocks/httpmocks/request_handler_mock.go b/testutil/mocks/httpmocks/request_handler_mock.go new file mode 100644 index 0000000..f17abce --- /dev/null +++ b/testutil/mocks/httpmocks/request_handler_mock.go @@ -0,0 +1,47 @@ +package httpmocks + +import ( + "git.defalsify.org/vise.git/engine" + "git.defalsify.org/vise.git/persist" + "git.defalsify.org/vise.git/resource" + "git.grassecon.net/urdt/ussd/internal/handlers" +) + +// MockRequestHandler implements handlers.RequestHandler interface for testing +type MockRequestHandler struct { + ProcessFunc func(handlers.RequestSession) (handlers.RequestSession, error) + GetConfigFunc func() engine.Config + GetEngineFunc func(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine + OutputFunc func(rs handlers.RequestSession) (handlers.RequestSession, error) + ResetFunc func(rs handlers.RequestSession) (handlers.RequestSession, error) + ShutdownFunc func() + GetRequestParserFunc func() handlers.RequestParser +} + +func (m *MockRequestHandler) Process(rqs handlers.RequestSession) (handlers.RequestSession, error) { + return m.ProcessFunc(rqs) +} + +func (m *MockRequestHandler) GetConfig() engine.Config { + return m.GetConfigFunc() +} + +func (m *MockRequestHandler) GetEngine(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine { + return m.GetEngineFunc(cfg, rs, pe) +} + +func (m *MockRequestHandler) Output(rs handlers.RequestSession) (handlers.RequestSession, error) { + return m.OutputFunc(rs) +} + +func (m *MockRequestHandler) Reset(rs handlers.RequestSession) (handlers.RequestSession, error) { + return m.ResetFunc(rs) +} + +func (m *MockRequestHandler) Shutdown() { + m.ShutdownFunc() +} + +func (m *MockRequestHandler) GetRequestParser() handlers.RequestParser { + return m.GetRequestParserFunc() +} diff --git a/testutil/mocks/httpmocks/requestparsermock.go b/testutil/mocks/httpmocks/request_parser_mock.go similarity index 100% rename from testutil/mocks/httpmocks/requestparsermock.go rename to testutil/mocks/httpmocks/request_parser_mock.go diff --git a/testutil/mocks/httpmocks/writermock.go b/testutil/mocks/httpmocks/writer_mock.go similarity index 100% rename from testutil/mocks/httpmocks/writermock.go rename to testutil/mocks/httpmocks/writer_mock.go diff --git a/testutil/testservice/accountservice.go b/testutil/testservice/account_service.go similarity index 100% rename from testutil/testservice/accountservice.go rename to testutil/testservice/account_service.go