Documentation
¶
Index ¶
- type HTTPServerMock
- type HealthCheckerMock
- func (mock *HealthCheckerMock) AddCheck(name string, checker healthcheck.Checker) error
- func (mock *HealthCheckerMock) AddCheckCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Handler(w http.ResponseWriter, req *http.Request)
- func (mock *HealthCheckerMock) HandlerCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Start(ctx context.Context)
- func (mock *HealthCheckerMock) StartCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Stop()
- func (mock *HealthCheckerMock) StopCalls() []struct{}
- type InitialiserMock
- func (mock *InitialiserMock) DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
- func (mock *InitialiserMock) DoGetAuthorisationMiddlewareCalls() []struct{ ... }
- func (mock *InitialiserMock) DoGetHTTPServer(bindAddr string, router http.Handler) service.HTTPServer
- func (mock *InitialiserMock) DoGetHTTPServerCalls() []struct{ ... }
- func (mock *InitialiserMock) DoGetHealthCheck(cfg *config.Config, buildTime string, gitCommit string, version string) (service.HealthChecker, error)
- func (mock *InitialiserMock) DoGetHealthCheckCalls() []struct{ ... }
- func (mock *InitialiserMock) DoGetMongoDB(ctx context.Context, cfg *config.Config) (service.PermissionsStore, error)
- func (mock *InitialiserMock) DoGetMongoDBCalls() []struct{ ... }
- type PermissionsStoreMock
- func (mock *PermissionsStoreMock) AddPolicy(ctx context.Context, policy *models.Policy) (*models.Policy, error)
- func (mock *PermissionsStoreMock) AddPolicyCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) Checker(ctx context.Context, state *healthcheck.CheckState) error
- func (mock *PermissionsStoreMock) CheckerCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) Close(ctx context.Context) error
- func (mock *PermissionsStoreMock) CloseCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) DeletePolicy(ctx context.Context, id string) error
- func (mock *PermissionsStoreMock) DeletePolicyCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) GetAllBundlePolicies(ctx context.Context) ([]*models.BundlePolicy, error)
- func (mock *PermissionsStoreMock) GetAllBundlePoliciesCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) GetAllRoles(ctx context.Context) ([]*models.Role, error)
- func (mock *PermissionsStoreMock) GetAllRolesCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) GetPolicy(ctx context.Context, id string) (*models.Policy, error)
- func (mock *PermissionsStoreMock) GetPolicyCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) GetRole(ctx context.Context, id string) (*models.Role, error)
- func (mock *PermissionsStoreMock) GetRoleCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) GetRoles(ctx context.Context, offset int, limit int) (*models.Roles, error)
- func (mock *PermissionsStoreMock) GetRolesCalls() []struct{ ... }
- func (mock *PermissionsStoreMock) UpdatePolicy(ctx context.Context, policy *models.Policy) (*models.UpdateResult, error)
- func (mock *PermissionsStoreMock) UpdatePolicyCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServerMock ¶
type HTTPServerMock struct {
// ListenAndServeFunc mocks the ListenAndServe method.
ListenAndServeFunc func() error
// ShutdownFunc mocks the Shutdown method.
ShutdownFunc func(ctx context.Context) error
// contains filtered or unexported fields
}
HTTPServerMock is a mock implementation of service.HTTPServer.
func TestSomethingThatUsesHTTPServer(t *testing.T) {
// make and configure a mocked service.HTTPServer
mockedHTTPServer := &HTTPServerMock{
ListenAndServeFunc: func() error {
panic("mock out the ListenAndServe method")
},
ShutdownFunc: func(ctx context.Context) error {
panic("mock out the Shutdown method")
},
}
// use mockedHTTPServer in code that requires service.HTTPServer
// and then make assertions.
}
func (*HTTPServerMock) ListenAndServe ¶
func (mock *HTTPServerMock) ListenAndServe() error
ListenAndServe calls ListenAndServeFunc.
func (*HTTPServerMock) ListenAndServeCalls ¶
func (mock *HTTPServerMock) ListenAndServeCalls() []struct { }
ListenAndServeCalls gets all the calls that were made to ListenAndServe. Check the length with:
len(mockedHTTPServer.ListenAndServeCalls())
func (*HTTPServerMock) Shutdown ¶
func (mock *HTTPServerMock) Shutdown(ctx context.Context) error
Shutdown calls ShutdownFunc.
func (*HTTPServerMock) ShutdownCalls ¶
func (mock *HTTPServerMock) ShutdownCalls() []struct { Ctx context.Context }
ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:
len(mockedHTTPServer.ShutdownCalls())
type HealthCheckerMock ¶
type HealthCheckerMock struct {
// AddCheckFunc mocks the AddCheck method.
AddCheckFunc func(name string, checker healthcheck.Checker) error
// HandlerFunc mocks the Handler method.
HandlerFunc func(w http.ResponseWriter, req *http.Request)
// StartFunc mocks the Start method.
StartFunc func(ctx context.Context)
// StopFunc mocks the Stop method.
StopFunc func()
// contains filtered or unexported fields
}
HealthCheckerMock is a mock implementation of service.HealthChecker.
func TestSomethingThatUsesHealthChecker(t *testing.T) {
// make and configure a mocked service.HealthChecker
mockedHealthChecker := &HealthCheckerMock{
AddCheckFunc: func(name string, checker healthcheck.Checker) error {
panic("mock out the AddCheck method")
},
HandlerFunc: func(w http.ResponseWriter, req *http.Request) {
panic("mock out the Handler method")
},
StartFunc: func(ctx context.Context) {
panic("mock out the Start method")
},
StopFunc: func() {
panic("mock out the Stop method")
},
}
// use mockedHealthChecker in code that requires service.HealthChecker
// and then make assertions.
}
func (*HealthCheckerMock) AddCheck ¶
func (mock *HealthCheckerMock) AddCheck(name string, checker healthcheck.Checker) error
AddCheck calls AddCheckFunc.
func (*HealthCheckerMock) AddCheckCalls ¶
func (mock *HealthCheckerMock) AddCheckCalls() []struct { Name string Checker healthcheck.Checker }
AddCheckCalls gets all the calls that were made to AddCheck. Check the length with:
len(mockedHealthChecker.AddCheckCalls())
func (*HealthCheckerMock) Handler ¶
func (mock *HealthCheckerMock) Handler(w http.ResponseWriter, req *http.Request)
Handler calls HandlerFunc.
func (*HealthCheckerMock) HandlerCalls ¶
func (mock *HealthCheckerMock) HandlerCalls() []struct { W http.ResponseWriter Req *http.Request }
HandlerCalls gets all the calls that were made to Handler. Check the length with:
len(mockedHealthChecker.HandlerCalls())
func (*HealthCheckerMock) Start ¶
func (mock *HealthCheckerMock) Start(ctx context.Context)
Start calls StartFunc.
func (*HealthCheckerMock) StartCalls ¶
func (mock *HealthCheckerMock) StartCalls() []struct { Ctx context.Context }
StartCalls gets all the calls that were made to Start. Check the length with:
len(mockedHealthChecker.StartCalls())
func (*HealthCheckerMock) StopCalls ¶
func (mock *HealthCheckerMock) StopCalls() []struct { }
StopCalls gets all the calls that were made to Stop. Check the length with:
len(mockedHealthChecker.StopCalls())
type InitialiserMock ¶
type InitialiserMock struct {
// DoGetAuthorisationMiddlewareFunc mocks the DoGetAuthorisationMiddleware method.
DoGetAuthorisationMiddlewareFunc func(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
// DoGetHTTPServerFunc mocks the DoGetHTTPServer method.
DoGetHTTPServerFunc func(bindAddr string, router http.Handler) service.HTTPServer
// DoGetHealthCheckFunc mocks the DoGetHealthCheck method.
DoGetHealthCheckFunc func(cfg *config.Config, buildTime string, gitCommit string, version string) (service.HealthChecker, error)
// DoGetMongoDBFunc mocks the DoGetMongoDB method.
DoGetMongoDBFunc func(ctx context.Context, cfg *config.Config) (service.PermissionsStore, error)
// contains filtered or unexported fields
}
InitialiserMock is a mock implementation of service.Initialiser.
func TestSomethingThatUsesInitialiser(t *testing.T) {
// make and configure a mocked service.Initialiser
mockedInitialiser := &InitialiserMock{
DoGetAuthorisationMiddlewareFunc: func(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error) {
panic("mock out the DoGetAuthorisationMiddleware method")
},
DoGetHTTPServerFunc: func(bindAddr string, router http.Handler) service.HTTPServer {
panic("mock out the DoGetHTTPServer method")
},
DoGetHealthCheckFunc: func(cfg *config.Config, buildTime string, gitCommit string, version string) (service.HealthChecker, error) {
panic("mock out the DoGetHealthCheck method")
},
DoGetMongoDBFunc: func(ctx context.Context, cfg *config.Config) (service.PermissionsStore, error) {
panic("mock out the DoGetMongoDB method")
},
}
// use mockedInitialiser in code that requires service.Initialiser
// and then make assertions.
}
func (*InitialiserMock) DoGetAuthorisationMiddleware ¶ added in v0.6.0
func (mock *InitialiserMock) DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
DoGetAuthorisationMiddleware calls DoGetAuthorisationMiddlewareFunc.
func (*InitialiserMock) DoGetAuthorisationMiddlewareCalls ¶ added in v0.6.0
func (mock *InitialiserMock) DoGetAuthorisationMiddlewareCalls() []struct { Ctx context.Context AuthorisationConfig *authorisation.Config }
DoGetAuthorisationMiddlewareCalls gets all the calls that were made to DoGetAuthorisationMiddleware. Check the length with:
len(mockedInitialiser.DoGetAuthorisationMiddlewareCalls())
func (*InitialiserMock) DoGetHTTPServer ¶
func (mock *InitialiserMock) DoGetHTTPServer(bindAddr string, router http.Handler) service.HTTPServer
DoGetHTTPServer calls DoGetHTTPServerFunc.
func (*InitialiserMock) DoGetHTTPServerCalls ¶
func (mock *InitialiserMock) DoGetHTTPServerCalls() []struct { BindAddr string Router http.Handler }
DoGetHTTPServerCalls gets all the calls that were made to DoGetHTTPServer. Check the length with:
len(mockedInitialiser.DoGetHTTPServerCalls())
func (*InitialiserMock) DoGetHealthCheck ¶
func (mock *InitialiserMock) DoGetHealthCheck(cfg *config.Config, buildTime string, gitCommit string, version string) (service.HealthChecker, error)
DoGetHealthCheck calls DoGetHealthCheckFunc.
func (*InitialiserMock) DoGetHealthCheckCalls ¶
func (mock *InitialiserMock) DoGetHealthCheckCalls() []struct { Cfg *config.Config BuildTime string GitCommit string Version string }
DoGetHealthCheckCalls gets all the calls that were made to DoGetHealthCheck. Check the length with:
len(mockedInitialiser.DoGetHealthCheckCalls())
func (*InitialiserMock) DoGetMongoDB ¶ added in v0.0.2
func (mock *InitialiserMock) DoGetMongoDB(ctx context.Context, cfg *config.Config) (service.PermissionsStore, error)
DoGetMongoDB calls DoGetMongoDBFunc.
func (*InitialiserMock) DoGetMongoDBCalls ¶ added in v0.0.2
func (mock *InitialiserMock) DoGetMongoDBCalls() []struct { Ctx context.Context Cfg *config.Config }
DoGetMongoDBCalls gets all the calls that were made to DoGetMongoDB. Check the length with:
len(mockedInitialiser.DoGetMongoDBCalls())
type PermissionsStoreMock ¶ added in v0.0.2
type PermissionsStoreMock struct {
// AddPolicyFunc mocks the AddPolicy method.
AddPolicyFunc func(ctx context.Context, policy *models.Policy) (*models.Policy, error)
// CheckerFunc mocks the Checker method.
CheckerFunc func(ctx context.Context, state *healthcheck.CheckState) error
// CloseFunc mocks the Close method.
CloseFunc func(ctx context.Context) error
// DeletePolicyFunc mocks the DeletePolicy method.
DeletePolicyFunc func(ctx context.Context, id string) error
// GetAllBundlePoliciesFunc mocks the GetAllBundlePolicies method.
GetAllBundlePoliciesFunc func(ctx context.Context) ([]*models.BundlePolicy, error)
// GetAllRolesFunc mocks the GetAllRoles method.
GetAllRolesFunc func(ctx context.Context) ([]*models.Role, error)
// GetPolicyFunc mocks the GetPolicy method.
GetPolicyFunc func(ctx context.Context, id string) (*models.Policy, error)
// GetRoleFunc mocks the GetRole method.
GetRoleFunc func(ctx context.Context, id string) (*models.Role, error)
// GetRolesFunc mocks the GetRoles method.
GetRolesFunc func(ctx context.Context, offset int, limit int) (*models.Roles, error)
// UpdatePolicyFunc mocks the UpdatePolicy method.
UpdatePolicyFunc func(ctx context.Context, policy *models.Policy) (*models.UpdateResult, error)
// contains filtered or unexported fields
}
PermissionsStoreMock is a mock implementation of service.PermissionsStore.
func TestSomethingThatUsesPermissionsStore(t *testing.T) {
// make and configure a mocked service.PermissionsStore
mockedPermissionsStore := &PermissionsStoreMock{
AddPolicyFunc: func(ctx context.Context, policy *models.Policy) (*models.Policy, error) {
panic("mock out the AddPolicy method")
},
CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
panic("mock out the Checker method")
},
CloseFunc: func(ctx context.Context) error {
panic("mock out the Close method")
},
DeletePolicyFunc: func(ctx context.Context, id string) error {
panic("mock out the DeletePolicy method")
},
GetAllBundlePoliciesFunc: func(ctx context.Context) ([]*models.BundlePolicy, error) {
panic("mock out the GetAllBundlePolicies method")
},
GetAllRolesFunc: func(ctx context.Context) ([]*models.Role, error) {
panic("mock out the GetAllRoles method")
},
GetPolicyFunc: func(ctx context.Context, id string) (*models.Policy, error) {
panic("mock out the GetPolicy method")
},
GetRoleFunc: func(ctx context.Context, id string) (*models.Role, error) {
panic("mock out the GetRole method")
},
GetRolesFunc: func(ctx context.Context, offset int, limit int) (*models.Roles, error) {
panic("mock out the GetRoles method")
},
UpdatePolicyFunc: func(ctx context.Context, policy *models.Policy) (*models.UpdateResult, error) {
panic("mock out the UpdatePolicy method")
},
}
// use mockedPermissionsStore in code that requires service.PermissionsStore
// and then make assertions.
}
func (*PermissionsStoreMock) AddPolicy ¶ added in v0.5.0
func (mock *PermissionsStoreMock) AddPolicy(ctx context.Context, policy *models.Policy) (*models.Policy, error)
AddPolicy calls AddPolicyFunc.
func (*PermissionsStoreMock) AddPolicyCalls ¶ added in v0.5.0
func (mock *PermissionsStoreMock) AddPolicyCalls() []struct { Ctx context.Context Policy *models.Policy }
AddPolicyCalls gets all the calls that were made to AddPolicy. Check the length with:
len(mockedPermissionsStore.AddPolicyCalls())
func (*PermissionsStoreMock) Checker ¶ added in v0.0.2
func (mock *PermissionsStoreMock) Checker(ctx context.Context, state *healthcheck.CheckState) error
Checker calls CheckerFunc.
func (*PermissionsStoreMock) CheckerCalls ¶ added in v0.0.2
func (mock *PermissionsStoreMock) CheckerCalls() []struct { Ctx context.Context State *healthcheck.CheckState }
CheckerCalls gets all the calls that were made to Checker. Check the length with:
len(mockedPermissionsStore.CheckerCalls())
func (*PermissionsStoreMock) Close ¶ added in v0.0.2
func (mock *PermissionsStoreMock) Close(ctx context.Context) error
Close calls CloseFunc.
func (*PermissionsStoreMock) CloseCalls ¶ added in v0.0.2
func (mock *PermissionsStoreMock) CloseCalls() []struct { Ctx context.Context }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedPermissionsStore.CloseCalls())
func (*PermissionsStoreMock) DeletePolicy ¶ added in v0.8.0
func (mock *PermissionsStoreMock) DeletePolicy(ctx context.Context, id string) error
DeletePolicy calls DeletePolicyFunc.
func (*PermissionsStoreMock) DeletePolicyCalls ¶ added in v0.8.0
func (mock *PermissionsStoreMock) DeletePolicyCalls() []struct { Ctx context.Context ID string }
DeletePolicyCalls gets all the calls that were made to DeletePolicy. Check the length with:
len(mockedPermissionsStore.DeletePolicyCalls())
func (*PermissionsStoreMock) GetAllBundlePolicies ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetAllBundlePolicies(ctx context.Context) ([]*models.BundlePolicy, error)
GetAllBundlePolicies calls GetAllBundlePoliciesFunc.
func (*PermissionsStoreMock) GetAllBundlePoliciesCalls ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetAllBundlePoliciesCalls() []struct { Ctx context.Context }
GetAllBundlePoliciesCalls gets all the calls that were made to GetAllBundlePolicies. Check the length with:
len(mockedPermissionsStore.GetAllBundlePoliciesCalls())
func (*PermissionsStoreMock) GetAllRoles ¶ added in v0.5.0
GetAllRoles calls GetAllRolesFunc.
func (*PermissionsStoreMock) GetAllRolesCalls ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetAllRolesCalls() []struct { Ctx context.Context }
GetAllRolesCalls gets all the calls that were made to GetAllRoles. Check the length with:
len(mockedPermissionsStore.GetAllRolesCalls())
func (*PermissionsStoreMock) GetPolicyCalls ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetPolicyCalls() []struct { Ctx context.Context ID string }
GetPolicyCalls gets all the calls that were made to GetPolicy. Check the length with:
len(mockedPermissionsStore.GetPolicyCalls())
func (*PermissionsStoreMock) GetRoleCalls ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetRoleCalls() []struct { Ctx context.Context ID string }
GetRoleCalls gets all the calls that were made to GetRole. Check the length with:
len(mockedPermissionsStore.GetRoleCalls())
func (*PermissionsStoreMock) GetRoles ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetRoles(ctx context.Context, offset int, limit int) (*models.Roles, error)
GetRoles calls GetRolesFunc.
func (*PermissionsStoreMock) GetRolesCalls ¶ added in v0.5.0
func (mock *PermissionsStoreMock) GetRolesCalls() []struct { Ctx context.Context Offset int Limit int }
GetRolesCalls gets all the calls that were made to GetRoles. Check the length with:
len(mockedPermissionsStore.GetRolesCalls())
func (*PermissionsStoreMock) UpdatePolicy ¶ added in v0.8.0
func (mock *PermissionsStoreMock) UpdatePolicy(ctx context.Context, policy *models.Policy) (*models.UpdateResult, error)
UpdatePolicy calls UpdatePolicyFunc.
func (*PermissionsStoreMock) UpdatePolicyCalls ¶ added in v0.8.0
func (mock *PermissionsStoreMock) UpdatePolicyCalls() []struct { Ctx context.Context Policy *models.Policy }
UpdatePolicyCalls gets all the calls that were made to UpdatePolicy. Check the length with:
len(mockedPermissionsStore.UpdatePolicyCalls())