Documentation ¶
Overview ¶
Package testkit provides functionalities for testing the APIs.
Index ¶
- Variables
- type CredentialsProvider
- type CredentialsProviderMocker
- type Expectation
- type Server
- func (s *Server) AccessToken() auth.Token
- func (s *Server) Expect(method string, requestURI interface{}) Expectation
- func (s *Server) ExpectDelete(requestURI interface{}) Expectation
- func (s *Server) ExpectGet(requestURI interface{}) Expectation
- func (s *Server) ExpectHead(requestURI interface{}) Expectation
- func (s *Server) ExpectPatch(requestURI interface{}) Expectation
- func (s *Server) ExpectPost(requestURI interface{}) Expectation
- func (s *Server) ExpectPut(requestURI interface{}) Expectation
- func (s *Server) RefreshToken() auth.Token
- func (s *Server) RequestToken() auth.Token
- func (s *Server) WithAccessToken(token string) *Server
- func (s *Server) WithPlanner(p planner.Planner) *Server
- func (s *Server) WithRefreshToken(token string) *Server
- func (s *Server) WithRequestToken(token string) *Server
- type ServerMocker
- type ServerOption
- func WithAuthLoginURLFailure() ServerOption
- func WithAuthLoginURLSuccess() ServerOption
- func WithAuthSuccess(username, password string) ServerOption
- func WithAuthTokenFailure(username, password string) ServerOption
- func WithAuthTokenSuccess(username, password string) ServerOption
- func WithFindAllTransactionsInRange(walletID string, from time.Time, to time.Time, ...) ServerOption
- type TestingT
Constants ¶
This section is empty.
Variables ¶
var NoMockCredentialsProvider = MockCredentialsProvider()
NoMockCredentialsProvider is no mock CredentialsProvider.
Functions ¶
This section is empty.
Types ¶
type CredentialsProvider ¶
CredentialsProvider is a CredentialsProvider.
func (*CredentialsProvider) Password ¶
func (c *CredentialsProvider) Password() string
Password satisfies CredentialsProvider.
func (*CredentialsProvider) Username ¶
func (c *CredentialsProvider) Username() string
Username satisfies CredentialsProvider.
type CredentialsProviderMocker ¶
type CredentialsProviderMocker func(tb testing.TB) *CredentialsProvider
CredentialsProviderMocker is CredentialsProvider mocker.
func MockCredentialsProvider ¶
func MockCredentialsProvider(mocks ...func(p *CredentialsProvider)) CredentialsProviderMocker
MockCredentialsProvider creates CredentialsProvider mock with cleanup to ensure all the expectations are met.
type Expectation ¶ added in v0.2.0
type Expectation = httpmock.Expectation
Expectation is an alias of httpmock.Expectation.
type Server ¶
Server is a wrapped httpmock.Server to provide more functionalities for testing MoneyLover APIs.
func (*Server) AccessToken ¶
AccessToken returns the accessToken.
func (*Server) Expect ¶
func (s *Server) Expect(method string, requestURI interface{}) Expectation
Expect expects a request with Bearer Authorization.
Server.Expect(http.MethodGet, "/path").
func (*Server) ExpectDelete ¶
func (s *Server) ExpectDelete(requestURI interface{}) Expectation
ExpectDelete expects a request with Bearer Authorization.
Server.ExpectDelete("/path")
func (*Server) ExpectGet ¶
func (s *Server) ExpectGet(requestURI interface{}) Expectation
ExpectGet expects a request with Bearer Authorization.
Server.ExpectGet("/path")
func (*Server) ExpectHead ¶
func (s *Server) ExpectHead(requestURI interface{}) Expectation
ExpectHead expects a request with Bearer Authorization.
Server.ExpectHead("/path")
func (*Server) ExpectPatch ¶
func (s *Server) ExpectPatch(requestURI interface{}) Expectation
ExpectPatch expects a request with Bearer Authorization.
Server.ExpectPatch("/path")
func (*Server) ExpectPost ¶
func (s *Server) ExpectPost(requestURI interface{}) Expectation
ExpectPost expects a request with Bearer Authorization.
Server.ExpectPost("/path")
func (*Server) ExpectPut ¶
func (s *Server) ExpectPut(requestURI interface{}) Expectation
ExpectPut expects a request with Bearer Authorization.
Server.ExpectPut("/path")
func (*Server) RefreshToken ¶
RefreshToken returns the refreshToken.
func (*Server) RequestToken ¶
RequestToken returns the requestToken.
func (*Server) WithAccessToken ¶
WithAccessToken sets the accessToken.
func (*Server) WithPlanner ¶ added in v0.2.0
WithPlanner sets planner.
func (*Server) WithRefreshToken ¶
WithRefreshToken sets the refreshToken.
func (*Server) WithRequestToken ¶
WithRequestToken sets the accessToken.
type ServerMocker ¶
ServerMocker is a function that applies expectations to the mocked server.
func MockEmptyServer ¶
func MockEmptyServer(mocks ...ServerOption) ServerMocker
MockEmptyServer mocks a MoneyLover API server.
func MockServer ¶
func MockServer( username, password string, mocks ...ServerOption, ) ServerMocker
MockServer mocks a server with successful authentication workflow.
type ServerOption ¶
type ServerOption = func(s *Server)
ServerOption is an option to configure Server.
func WithAuthLoginURLFailure ¶
func WithAuthLoginURLFailure() ServerOption
WithAuthLoginURLFailure expects a request for login URL and returns a 500.
func WithAuthLoginURLSuccess ¶
func WithAuthLoginURLSuccess() ServerOption
WithAuthLoginURLSuccess expects a request for login URL.
func WithAuthSuccess ¶
func WithAuthSuccess(username, password string) ServerOption
WithAuthSuccess expects a success login workflow.
func WithAuthTokenFailure ¶
func WithAuthTokenFailure(username, password string) ServerOption
WithAuthTokenFailure expects a request for login and returns a 401.
func WithAuthTokenSuccess ¶
func WithAuthTokenSuccess(username, password string) ServerOption
WithAuthTokenSuccess expects a request for login.
func WithFindAllTransactionsInRange ¶
func WithFindAllTransactionsInRange( walletID string, from time.Time, to time.Time, result []transaction.Transaction, ) ServerOption
WithFindAllTransactionsInRange sets expectations for finding all transactions in a range.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package auth provides functionalities for testing authentication.
|
Package auth provides functionalities for testing authentication. |
Package category provides functionalities for testing category contract.
|
Package category provides functionalities for testing category contract. |
Package transaction provides functionalities for testing transaction contract.
|
Package transaction provides functionalities for testing transaction contract. |
Package wallet provides functionalities for testing wallet contract.
|
Package wallet provides functionalities for testing wallet contract. |