Documentation ¶
Overview ¶
Package handler contains the logic of the server.
It contains sub-packages for the different use-cases (creating, editing, deleting...). The handler package contains interfaces for the sub-packages to access the store (store_interfaces.go). The handler package contains functions for the sub-packages to retrieve templates from the template package (template.go). The handler package contains functions for the sub-packages to access data from the context (context.go).
Testing the handlers: The handler packages provides functions, mocks and dummy-data for the sub-packages to test the handlers. The functions are in the files starting with testing_*.go
Index ¶
- Constants
- Variables
- func AssertResponse(t *testing.T, tested http.HandlerFunc, r *http.Request, ...)
- func EmptyRequest(method string) *http.Request
- func GetBaseTree() templates.LoadedTemplate
- func GetComments(r *http.Request) []*comment.Comment
- func GetLatestTestCaseVersion(r *http.Request, tc *test.Case) (*test.CaseVersion, error)
- func GetNoSideBarTree() templates.LoadedTemplate
- func GetPrintTree() templates.LoadedTemplate
- func GetSideBarTree() templates.LoadedTemplate
- func GetTestCaseVersion(r *http.Request, tc *test.Case) (*test.CaseVersion, error)
- func GetTestCases(tg TestCaseGetter, ids ...id.TestID) ([]test.Case, error)
- func GetTestSequenceVersion(r *http.Request, ts *test.Sequence) (*test.SequenceVersion, error)
- func GetVersion(r *http.Request, defaultVersion int) int
- func InvalidRequest(r *http.Request) errors.HandlerError
- func InvalidTCVersion() errors.HandlerError
- func InvalidVisibility() errors.HandlerError
- func NewFragmentRequest(ctx context.Context, method string, params url.Values, body string) *http.Request
- func NewRequest(ctx context.Context, method string, params url.Values, body string) *http.Request
- func PrintTmpl(ctx context.Context, template *template.Template, w io.Writer, r *http.Request)
- func SimpleContext(values map[interface{}]interface{}) context.Context
- func SimpleFragmentRequest(ctx context.Context, method string, params url.Values) *http.Request
- func SimpleRequest(ctx context.Context, method string, params url.Values) *http.Request
- func StringToInt(s string) int
- func Suite(t *testing.T, tests ...TestHandler)
- func UnauthorizedAccess(r *http.Request) errors.HandlerError
- type ActorExistenceCheckerMock
- type AuthMock
- type CallerCounterMock
- type CallerMock
- type CaseAdderMock
- type CaseDeleterMock
- type CaseGetterMock
- type CaseListerMock
- type CaseProtocolAdderMock
- type CaseProtocolGetterMock
- type CaseProtocolListerMock
- type CaseProtocolRenamerMock
- type CaseProtocolStoreMock
- type CaseRenamerMock
- type CaseSessionGetterMock
- type CaseSessionMock
- type CaseSessionSetterMock
- type CaseSessionUpdaterMock
- type CaseUpdaterMock
- type CommentAdder
- type CommentAdderMock
- type ContextEntities
- type GroupAdder
- type GroupAdderMock
- type GroupLister
- type GroupListerMock
- type ProjectAdder
- type ProjectAdderMock
- type ProjectDeleter
- type ProjectDeleterMock
- type ProjectExistenceMock
- type ProjectLister
- type ProjectListerMock
- func (m *ProjectListerMock) List() ([]*project.Project, error)
- func (m *ProjectListerMock) ListAll() ([]*project.Project, error)
- func (m *ProjectListerMock) ListForActor(actor id.ActorID) ([]*project.Project, error)
- func (m *ProjectListerMock) ListForMember(owner id.ActorID) ([]*project.Project, error)
- func (m *ProjectListerMock) ListForOwner(owner id.ActorID) ([]*project.Project, error)
- func (m *ProjectListerMock) ListInternal() ([]*project.Project, error)
- func (m *ProjectListerMock) ListPrivate(actor id.ActorID) ([]*project.Project, error)
- func (m *ProjectListerMock) ListPublic() ([]*project.Project, error)
- type ProtocolCaseRenamer
- type ProtocolListerMock
- type RegisterServerMock
- type ResponseMatcher
- type SequenceAdderMock
- type SequenceDeletionMock
- type SequenceListerMock
- type SequenceProtocolAdderMock
- type SequenceProtocolListerMock
- type SequenceRenameHandler
- type SequenceRenameHandlerMock
- type SequenceRenamerMock
- type SequenceSessionGetterMock
- type SequenceSessionMock
- type SequenceSessionSetterMock
- type SequenceUpdaterMock
- type TestCaseAdder
- type TestCaseDeleter
- type TestCaseGetter
- type TestCaseLister
- type TestCaseProtocolLister
- type TestCaseRenamer
- type TestCaseUpdater
- type TestExistenceCheckerMock
- type TestHandler
- type TestSequenceAdder
- type TestSequenceDeleter
- type TestSequenceLister
- type TestSequenceProtocolLister
- type TestSequenceRenamer
- type TestSequenceUpdater
- type TestSetUp
- type TimeSessionMock
- type UserLister
- type UserListerMock
- type UserRetrieverMock
Constants ¶
const ( ErrInvalidTestSequenceVersionTitle = "Invalid test sequence version." ErrInvalidTestSequenceVersion = "Your client tried to access an invalid version " + "of a test sequence. If you believe this is a bug please contact us via our " + IssueTracker + "." )
Error-messages for retrieving sequence versions from the request
const IssueTracker = "<a href='https://gitlab.com/stp-team/systemtestportal-webapp/issues'>issue tracker</a>"
IssueTracker is a html link to the issue board of the stp-repository
Variables ¶
var DummyGroup = &group.Group{ Name: "Dummy Group Name", Description: "Desc", Visibility: visibility.Public, }
DummyGroup is a group for testing purposes
var DummyMembership = &project.UserMembership{ User: "acc_name", Role: "Supervisor", MemberSince: time.Now().UTC().Round(time.Second), }
DummyMembership represents a membership that is used for testing purposes The user has the role "Supervisor" so he ca
var DummyProject = &project.Project{ Name: "DuckDuckGo.com", Description: "Test the online search engine DuckDuckGo.com", Visibility: visibility.Public, Owner: "default", Variants: map[string]*project.Variant{ "Chrome": { Name: "Chrome", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Firefox": { Name: "Firefox", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Microsoft Edge": { Name: "Microsoft Edge", Versions: []project.Version{ 0: {Name: "1.0.2"}, 1: {Name: "2.0.2"}, 2: {Name: "3.0.1"}, }, }, }, UserMembers: map[id.ActorID]project.UserMembership{ id.ActorID(DummyUser.Name): *DummyMembership, }, Roles: DummyRoles, CreationDate: time.Now().UTC().Round(time.Second), }
DummyProject contains a project for testing purposes
var DummyProjectInternal = &project.Project{ Name: "DuckDuckGo.com", Description: "Test the online search engine DuckDuckGo.com", Visibility: visibility.Internal, Owner: "default", Variants: map[string]*project.Variant{ "Chrome": { Name: "Chrome", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Firefox": { Name: "Firefox", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Microsoft Edge": { Name: "Microsoft Edge", Versions: []project.Version{ 0: {Name: "1.0.2"}, 1: {Name: "2.0.2"}, 2: {Name: "3.0.1"}, }, }, }, UserMembers: map[id.ActorID]project.UserMembership{ id.ActorID(DummyUser.Name): *DummyMembership, }, Roles: DummyRoles, CreationDate: time.Now().UTC().Round(time.Second), }
DummyProjectInternal contains an internal project for testing purposes
var DummyProjectPrivate = &project.Project{ Name: "DuckDuckGo.com", Description: "Test the online search engine DuckDuckGo.com", Visibility: visibility.Private, Owner: "default", Variants: map[string]*project.Variant{ "Chrome": { Name: "Chrome", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Firefox": { Name: "Firefox", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Microsoft Edge": { Name: "Microsoft Edge", Versions: []project.Version{ 0: {Name: "1.0.2"}, 1: {Name: "2.0.2"}, 2: {Name: "3.0.1"}, }, }, }, UserMembers: map[id.ActorID]project.UserMembership{ id.ActorID(DummyUser.Name): *DummyMembership, }, Roles: DummyRoles, CreationDate: time.Now().UTC().Round(time.Second), }
DummyProjectPrivate contains a project for testing purposes
var DummyRoles = map[project.RoleName]*project.Role{ "Supervisor": { Name: "Supervisor", Permissions: project.Permissions{ DisplayPermissions: project.DisplayPermissions{ DisplayProject: true, }, ExecutionPermissions: project.ExecutionPermissions{ Execute: true, }, CasePermissions: project.CasePermissions{ CreateCase: true, EditCase: true, DeleteCase: true, AssignCase: true, DuplicateCase: true, }, SequencePermissions: project.SequencePermissions{ CreateSequence: true, EditSequence: true, DeleteSequence: true, DuplicateSequence: true, AssignSequence: true, }, MemberPermissions: project.MemberPermissions{ EditMembers: true, }, SettingsPermissions: project.SettingsPermissions{ EditProject: true, DeleteProject: true, EditPermissions: true, }, }, }, "Manager": { Name: "Manager", Permissions: project.Permissions{ DisplayPermissions: project.DisplayPermissions{ DisplayProject: true, }, ExecutionPermissions: project.ExecutionPermissions{ Execute: true, }, CasePermissions: project.CasePermissions{ CreateCase: true, EditCase: true, DeleteCase: true, AssignCase: true, DuplicateCase: true, }, SequencePermissions: project.SequencePermissions{ CreateSequence: true, EditSequence: true, DeleteSequence: true, DuplicateSequence: true, AssignSequence: true, }, MemberPermissions: project.MemberPermissions{ EditMembers: false, }, SettingsPermissions: project.SettingsPermissions{ EditProject: false, DeleteProject: false, EditPermissions: false, }, }, }, "Tester": { Name: "Tester", Permissions: project.Permissions{ DisplayPermissions: project.DisplayPermissions{ DisplayProject: true, }, ExecutionPermissions: project.ExecutionPermissions{ Execute: true, }, CasePermissions: project.CasePermissions{ CreateCase: false, EditCase: false, DeleteCase: false, AssignCase: false, DuplicateCase: false, }, SequencePermissions: project.SequencePermissions{ CreateSequence: false, EditSequence: false, DuplicateSequence: false, DeleteSequence: false, AssignSequence: false, }, MemberPermissions: project.MemberPermissions{ EditMembers: false, }, SettingsPermissions: project.SettingsPermissions{ EditProject: false, DeleteProject: false, EditPermissions: false, }, }, }, }
DummyRoles are dummy roles for testing purposes
var DummyTestCase = &test.Case{ Name: "Test Case 1", TestCaseVersions: []test.CaseVersion{ { Description: "First Test Case", Variants: map[string]*project.Variant{}, Steps: []test.Step{ { Index: 1, Action: "Open the application", ExpectedResult: "The main screen should show", }, { Index: 2, Action: "Open the login page", ExpectedResult: "The login page should show", }, { Index: 3, Action: "Login with the test login", ExpectedResult: "The login should succeed", }, }, }, }, Project: DummyProject.ID(), }
DummyTestCase is a test case for testing purposes
var DummyTestCaseSUTVersions = &test.Case{ Name: "Test Case 1", TestCaseVersions: []test.CaseVersion{ { Description: "First Test Case", Variants: map[string]*project.Variant{ "Chrome": { Name: "Chrome", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Firefox": { Name: "Firefox", Versions: []project.Version{ 0: {Name: "1.0.1"}, 1: {Name: "2.0.1"}, 2: {Name: "3.0.5"}, }, }, "Microsoft Edge": { Name: "Microsoft Edge", Versions: []project.Version{ 0: {Name: "1.0.2"}, 1: {Name: "2.0.2"}, 2: {Name: "3.0.1"}, }, }, }, Steps: []test.Step{ { Index: 1, Action: "Open the application", ExpectedResult: "The main screen should show", }, { Index: 2, Action: "Open the login page", ExpectedResult: "The login page should show", }, { Index: 3, Action: "Login with the test login", ExpectedResult: "The login should succeed", }, }, }, }, Project: DummyProject.ID(), }
DummyTestCaseSUTVersions is a test case for testing purposes that contains sut-versions
var DummyTestSequence = &test.Sequence{ Name: "test-sequence-1", Labels: []project.Label{}, SequenceVersions: []test.SequenceVersion{ dummyTestSequenceVersion, }, }
DummyTestSequence is a sequence for testing purposes
var DummyTestSequenceJSON string
DummyTestSequenceJSON is sequence in json for testing purposes
var DummyUser = &user.User{
DisplayName: "DisplayName",
Name: "acc_name",
EMail: "test@example.com",
}
DummyUser is a user for testing purposes
DisplayName: "DisplayName",
Name: "unauthorized",
EMail: "un@authorized.com",
}DummyUserUnauthorized is a user that is is not authorized to send requests because he is not a member of a project
var EmptyCtx = &testContext{make(map[interface{}]interface{})}
EmptyCtx is an empty context for testing purpses
var ErrTest = errors.New("error was injected by a test to check reaction")
ErrTest is an error that can be used if your test needs to
var NoParams = url.Values{}
NoParams is simply an empty set of parameters for a request.
Functions ¶
func AssertResponse ¶ added in v1.0.0
func AssertResponse(t *testing.T, tested http.HandlerFunc, r *http.Request, matchers ...ResponseMatcher)
AssertResponse sends given request to given tested handler and runs given ResponseMatchers on it.
func EmptyRequest ¶ added in v1.0.0
EmptyRequest creates a simple test request with no parameters and no context attached to it.
func GetBaseTree ¶ added in v1.0.0
func GetBaseTree() templates.LoadedTemplate
GetBaseTree returns a loaded base template containing only utility function used by the templates.
func GetComments ¶ added in v1.0.0
GetComments gets the comments from a given request if they were stored there by middleware. If the comment slice is nil or not contained in the request, nil will be returned.
func GetLatestTestCaseVersion ¶ added in v1.0.0
GetLatestTestCaseVersion gets the version of a testcase from a request. If the request doesn't contain a version number the latest is assumed. If the number send by the request is not the latest version an error is returned.
func GetNoSideBarTree ¶ added in v1.0.0
func GetNoSideBarTree() templates.LoadedTemplate
GetNoSideBarTree returns a loaded template structure for a view not containing the sidebar.
func GetPrintTree ¶ added in v1.0.0
func GetPrintTree() templates.LoadedTemplate
GetPrintTree returns a loaded template structure for a print view .
func GetSideBarTree ¶ added in v1.0.0
func GetSideBarTree() templates.LoadedTemplate
GetSideBarTree returns a loaded template structure for a view containing the sidebar.
func GetTestCaseVersion ¶ added in v1.0.0
GetTestCaseVersion gets the version of a testcase from a request. If the request doesn't contain a version number the latest is assumed. If the number send by the request is out of the range of possible versions an error is returned.
func GetTestCases ¶ added in v1.0.0
GetTestCases returns the testcase objects of the given ids
func GetTestSequenceVersion ¶ added in v1.0.0
GetTestSequenceVersion gets the version of a testsequence from a request. If the request doesn't contain a version number the latest is assumed. If the number send by the request is out of the range of possible versions an error is returned.
func GetVersion ¶ added in v1.0.0
GetVersion gets the version field from a request. Returns defaultVersion if the version is empty. Returns -1 if the version is not an integer.
func InvalidRequest ¶ added in v1.0.0
func InvalidRequest(r *http.Request) errors.HandlerError
InvalidRequest returns an error describing that the request contained no or invalid information.
func InvalidTCVersion ¶
func InvalidTCVersion() errors.HandlerError
InvalidTCVersion returns an ErrorMessage describing that the test case version is not valid
func InvalidVisibility ¶
func InvalidVisibility() errors.HandlerError
InvalidVisibility returns an ErrorMessage describing that a value is not valid.
func NewFragmentRequest ¶ added in v1.0.0
func NewFragmentRequest(ctx context.Context, method string, params url.Values, body string) *http.Request
NewFragmentRequest is used to create a request for testing.
func NewRequest ¶ added in v1.0.0
NewRequest is used to create a request for testing.
func PrintTmpl ¶ added in v1.0.0
PrintTmpl prints given template with given context into given writer. If an error occurs, an error response is written to the writer instead of the executed template's content.
If the given writer was a http.ResponseWriter the status code http.StatusInternalServerError will be written to its header if an error occurred.
func SimpleContext ¶ added in v1.0.0
SimpleContext returns a context made of given map. It is a very simple implementation of a context.Context.
func SimpleFragmentRequest ¶ added in v1.0.0
SimpleFragmentRequest is used to create a simple request for testing.
func SimpleRequest ¶ added in v1.0.0
SimpleRequest is used to create a simple request for testing.
func StringToInt ¶ added in v1.0.0
StringToInt gets a string and converts it to int. Returns -1 if the string cannot be converted to an int.
func Suite ¶ added in v1.0.0
func Suite(t *testing.T, tests ...TestHandler)
Suite runs several handlers test as sub tests of the current test.
func UnauthorizedAccess ¶ added in v1.0.0
func UnauthorizedAccess(r *http.Request) errors.HandlerError
UnauthorizedAccess returns an ErrorMessage describing that the user is not authorized
Types ¶
type ActorExistenceCheckerMock ¶ added in v1.0.0
type ActorExistenceCheckerMock struct { CallerMock Exst bool // contains filtered or unexported fields }
ActorExistenceCheckerMock mocks the ActorExistenceChecker
type AuthMock ¶ added in v1.0.0
type AuthMock struct { GivenIdentifier string GivenPassword string // contains filtered or unexported fields }
AuthMock mocks the Auth interface
func NewAuthMock ¶ added in v1.0.0
NewAuthMock creates a new Auth mock
type CallerCounterMock ¶ added in v1.0.0
type CallerCounterMock interface { // Calls returns the number of calls made to the mock. Calls() int }
CallerCounterMock is an interface for the CallerMock to count the calls made to the mock
type CallerMock ¶ added in v1.0.0
type CallerMock struct {
Called int
}
CallerMock mocks the Caller
func (*CallerMock) Calls ¶ added in v1.0.0
func (m *CallerMock) Calls() int
Calls returns the number of calls made to the mock.
type CaseAdderMock ¶ added in v1.0.0
type CaseAdderMock struct { CallerMock *test.Case Err error }
CaseAdderMock is a mock of the CaseAdder
type CaseDeleterMock ¶ added in v1.0.0
type CaseDeleterMock struct { CallerMock id.TestID }
CaseDeleterMock mocks the CaseDeleter
type CaseGetterMock ¶ added in v1.0.0
type CaseGetterMock struct { CallerMock CaseID id.TestID }
CaseGetterMock mocks the CaseGetter
type CaseListerMock ¶ added in v1.0.0
type CaseListerMock struct { CallerMock Project id.ProjectID Err error }
CaseListerMock mocks the CaseLister
type CaseProtocolAdderMock ¶ added in v1.1.0
type CaseProtocolAdderMock struct { CallerMock CaseExecutionProtocol test.CaseExecutionProtocol Err error }
CaseProtocolAdderMock mocks the CaseProtocolAdder interface
func (*CaseProtocolAdderMock) AddCaseProtocol ¶ added in v1.1.0
func (caseProtocolAdderMock *CaseProtocolAdderMock) AddCaseProtocol(r *test.CaseExecutionProtocol) (err error)
AddCaseProtocol mocks adding a case protocol to the store
type CaseProtocolGetterMock ¶ added in v1.1.0
type CaseProtocolGetterMock struct { CallerMock CaseExecutionProtocol test.CaseExecutionProtocol ProtocolID id.ProtocolID Err error }
CaseProtocolGetterMock mocks the CaseProtocolGetter interface
func (*CaseProtocolGetterMock) GetCaseExecutionProtocol ¶ added in v1.1.0
func (caseProtocolGetterMock *CaseProtocolGetterMock) GetCaseExecutionProtocol(protocolID id.ProtocolID) ( test.CaseExecutionProtocol, error)
GetCaseExecutionProtocol mocks getting a case protocol from the session
type CaseProtocolListerMock ¶ added in v1.0.0
type CaseProtocolListerMock struct { CallerMock Protocols []test.CaseExecutionProtocol Err error // contains filtered or unexported fields }
CaseProtocolListerMock mocks the CaseProtocolsLister
func (*CaseProtocolListerMock) GetCaseExecutionProtocols ¶ added in v1.0.0
func (m *CaseProtocolListerMock) GetCaseExecutionProtocols(testCaseID id.TestID) ([]test.CaseExecutionProtocol, error)
GetCaseExecutionProtocols mocks retrieving protocols of a case
type CaseProtocolRenamerMock ¶ added in v1.0.0
type CaseProtocolRenamerMock struct { CallerMock Old id.TestID New id.TestID }
CaseProtocolRenamerMock mocks the CaseProtocolRenamer
func (*CaseProtocolRenamerMock) HandleCaseRename ¶ added in v1.0.0
func (m *CaseProtocolRenamerMock) HandleCaseRename(old, new id.TestID) error
HandleCaseRename mocks renaming a test
type CaseProtocolStoreMock ¶ added in v1.1.0
type CaseProtocolStoreMock struct { CallerMock TestCaseID id.TestID CaseExecutionProtocols []test.CaseExecutionProtocol CaseProtocolAdderMock CaseProtocolGetterMock Err error }
CaseProtocolStoreMock mocks the CaseProtocolStore interface
func (*CaseProtocolStoreMock) GetCaseExecutionProtocols ¶ added in v1.1.0
func (caseProtocolStoreMock *CaseProtocolStoreMock) GetCaseExecutionProtocols(testCaseID id.TestID) ( []test.CaseExecutionProtocol, error)
GetCaseExecutionProtocols mocks getting all protocol of a case
type CaseRenamerMock ¶ added in v1.0.0
type CaseRenamerMock struct { CallerMock Old id.TestID New id.TestID }
CaseRenamerMock mocks the CaseRenamer
type CaseSessionGetterMock ¶ added in v1.1.0
type CaseSessionGetterMock struct { CallerMock CaseExecutionProtocol *test.CaseExecutionProtocol Err error }
CaseSessionGetterMock mocks the CaseSessionGetter interface
func (*CaseSessionGetterMock) GetCurrentCaseProtocol ¶ added in v1.1.0
func (csgm *CaseSessionGetterMock) GetCurrentCaseProtocol(r *http.Request) (*test.CaseExecutionProtocol, error)
GetCurrentCaseProtocol mocks getting the current case protocol
type CaseSessionMock ¶ added in v1.1.0
type CaseSessionMock struct { CallerMock CaseSessionUpdaterMock TimeSessionMock Err error }
CaseSessionMock mocks the CaseSession interface
func (*CaseSessionMock) RemoveCurrentCaseProtocol ¶ added in v1.1.0
func (csm *CaseSessionMock) RemoveCurrentCaseProtocol(w http.ResponseWriter, r *http.Request) error
RemoveCurrentCaseProtocol mocks removing the current case protocol from the session
type CaseSessionSetterMock ¶ added in v1.1.0
type CaseSessionSetterMock struct { CallerMock Err error }
CaseSessionSetterMock mocks the CaseSessionSetter interface
func (*CaseSessionSetterMock) SetCurrentCaseProtocol ¶ added in v1.1.0
func (cssm *CaseSessionSetterMock) SetCurrentCaseProtocol(w http.ResponseWriter, r *http.Request, protocol *test.CaseExecutionProtocol) error
SetCurrentCaseProtocol mocks setting the current case protocol
type CaseSessionUpdaterMock ¶ added in v1.1.0
type CaseSessionUpdaterMock struct { CallerMock CaseSessionGetterMock CaseSessionSetterMock }
CaseSessionUpdaterMock mocks the CaseSessionUpdater interface
type CaseUpdaterMock ¶ added in v1.0.0
type CaseUpdaterMock struct { CaseDeleterMock CaseAdderMock CaseRenamerMock }
CaseUpdaterMock mocks the CaseUpdater
type CommentAdder ¶ added in v0.10.0
type CommentAdder interface { // Add stores a comment for the given test case, project and container Add(c *comment.Comment) error }
CommentAdder is used to store a comment to the store
type CommentAdderMock ¶ added in v1.0.0
type CommentAdderMock struct { CallerMock Comment *comment.Comment }
CommentAdderMock mocks the CommentAdder
type ContextEntities ¶ added in v1.0.0
type ContextEntities struct { User *user.User ContainerID id.ActorID Project *project.Project Case *test.Case Sequence *test.Sequence Err error }
ContextEntities contains every entity that a handler could need for handling requests. These are entities like the project, user, case, sequence etc.
func GetContextEntities ¶ added in v1.0.0
func GetContextEntities(r *http.Request) *ContextEntities
GetContextEntities returns all entities that are in the request. Entities are a project, user case, sequence or container. If an entity could not be retrieved, the entity is nil.
Any error that occurs while retrieving the entities is logged. The Err in the ContextEntities is an InvalidRequest error.
type GroupAdder ¶ added in v0.8.0
GroupAdder is used to add groups to the storage.
type GroupAdderMock ¶ added in v1.0.0
type GroupAdderMock struct { CallerMock Err error // contains filtered or unexported fields }
GroupAdderMock mocks the GroupAdder
type GroupLister ¶ added in v0.8.0
type GroupLister interface { // List returns a list of groups in the system List() ([]*group.Group, error) }
GroupLister is used to list all groups in the system.
type GroupListerMock ¶ added in v1.0.0
type GroupListerMock struct { CallerMock Groups []*group.Group Err error }
GroupListerMock mocks the GroupLister
type ProjectAdder ¶ added in v0.8.0
type ProjectAdder interface { // Add stores a new project. The first argument is used to identify the container for the project Add(*project.Project) error }
ProjectAdder is used to add projects to the storage.
type ProjectAdderMock ¶ added in v1.0.0
type ProjectAdderMock struct { CallerMock *project.Project Err error }
ProjectAdderMock mocks the ProjectAdder
type ProjectDeleter ¶ added in v0.10.0
type ProjectDeleter interface { // Delete removes an existing project. The first argument is used to identify the container // and the second to identify the project Delete(projectID id.ProjectID) error }
ProjectDeleter is used to delete the reference of an existing project from storage
type ProjectDeleterMock ¶ added in v1.0.0
type ProjectDeleterMock struct { CallerMock id.ProjectID Err error }
ProjectDeleterMock mocks the ProjectDeleter
type ProjectExistenceMock ¶ added in v1.0.0
type ProjectExistenceMock struct { CallerMock id.ProjectID Exst bool }
ProjectExistenceMock mocks the ProjectExistenceChecker
type ProjectLister ¶ added in v0.8.0
type ProjectLister interface { // List returns a list of projects in the system List() ([]*project.Project, error) // ListForOwner returns the projects for an owner ListForOwner(id.ActorID) ([]*project.Project, error) // ListForMember returns all projects where the actor is a member ListForMember(id.ActorID) ([]*project.Project, error) // ListForActor returns all projects that the actor has access to ListForActor(id.ActorID) ([]*project.Project, error) // ListAll returns all projects in the system ListAll() ([]*project.Project, error) // ListPublic returns all public projects in the system ListPublic() ([]*project.Project, error) // ListInternal returns all internal projects in the system ListInternal() ([]*project.Project, error) // ListPrivate returns all private projects for an actor ListPrivate(id.ActorID) ([]*project.Project, error) }
ProjectLister is used to list all projects in the system.
type ProjectListerMock ¶ added in v1.0.0
type ProjectListerMock struct { CallerMock Projects []*project.Project Err error }
ProjectListerMock mocks the ProjectLister
func (*ProjectListerMock) List ¶ added in v1.0.0
func (m *ProjectListerMock) List() ([]*project.Project, error)
List mocks listing projects
func (*ProjectListerMock) ListAll ¶ added in v1.1.0
func (m *ProjectListerMock) ListAll() ([]*project.Project, error)
ListAll mocks listing projects
func (*ProjectListerMock) ListForActor ¶ added in v1.1.0
ListForActor mocks listing all projects that the actor has access to
func (*ProjectListerMock) ListForMember ¶ added in v1.1.0
ListForMember mocks listing projects where the actor is a member
func (*ProjectListerMock) ListForOwner ¶ added in v1.1.0
ListForOwner mocks listing projects for an owner
func (*ProjectListerMock) ListInternal ¶ added in v1.1.0
func (m *ProjectListerMock) ListInternal() ([]*project.Project, error)
ListInternal mocks listing internal projects
func (*ProjectListerMock) ListPrivate ¶ added in v1.1.0
ListPrivate mocks listing private projects
func (*ProjectListerMock) ListPublic ¶ added in v1.1.0
func (m *ProjectListerMock) ListPublic() ([]*project.Project, error)
List mocks listing projects
type ProtocolCaseRenamer ¶ added in v1.0.0
type ProtocolCaseRenamer interface { // HandleCaseRename updates the protocol store after a test case has been renamed HandleCaseRename(old, new id.TestID) error }
ProtocolCaseRenamer is used to handle renames.
type ProtocolListerMock ¶ added in v1.1.0
type ProtocolListerMock struct { CallerMock TestVersionID id.TestVersionID ProtocolIDs []id.ProtocolID Err error }
ProtocolListerMock mocks the ProtocolLister interface
func (*ProtocolListerMock) GetTestVersionProtocols ¶ added in v1.1.0
func (protocolListerMock *ProtocolListerMock) GetTestVersionProtocols(testVersionID id.TestVersionID) ([]id.ProtocolID, error)
GetTestVersionProtocols mocks getting the protocols of a test version
type RegisterServerMock ¶ added in v1.0.0
type RegisterServerMock struct { GetUserIDIn id.ActorID GetUserMailIn string GetUserUserOut *user.User GetUserFoundOut bool AddUserUserIn *user.PasswordUser AddUserErrorOut error }
RegisterServerMock mocks the RegisterServer
func (*RegisterServerMock) Add ¶ added in v1.0.0
func (usm *RegisterServerMock) Add(u *user.PasswordUser) error
Add mocks adding a user to the store
type ResponseMatcher ¶ added in v1.0.0
ResponseMatcher is used to check a condition on a response that a handler gave.
func HasBody ¶ added in v1.0.0
func HasBody(expectedBody string) ResponseMatcher
HasBody is a matcher that test if the response has given body or not. Whitespace will be trimmed from the body and given string.
func HasCalls ¶ added in v1.0.0
func HasCalls(mock CallerCounterMock, number int) ResponseMatcher
HasCalls is a simple matcher that checks whether given mock has a certain number of calls.
func HasStatus ¶ added in v1.0.0
func HasStatus(expectedStatus int) ResponseMatcher
HasStatus is a simple matcher that checks whether teh response has given status code.
func Matches ¶ added in v1.0.0
func Matches(matchers ...ResponseMatcher) []ResponseMatcher
Matches is a utility method to get a ResponseMatcher array the easy way.
type SequenceAdderMock ¶ added in v1.0.0
type SequenceAdderMock struct { CallerMock TestSequence *test.Sequence Err error }
SequenceAdderMock mocks the SequenceAdder
type SequenceDeletionMock ¶ added in v1.0.0
type SequenceDeletionMock struct { CallerMock ID id.TestID }
SequenceDeletionMock mocks the SequenceDeleter
type SequenceListerMock ¶ added in v1.0.0
type SequenceListerMock struct { CallerMock Project id.ProjectID Err error }
SequenceListerMock mocks the SequenceLister
type SequenceProtocolAdderMock ¶ added in v1.1.0
type SequenceProtocolAdderMock struct { CallerMock SequenceExecutionProtocol *test.SequenceExecutionProtocol Err error }
SequenceProtocolAdderMock mocks the SequenceProtocolAdder interface
func (*SequenceProtocolAdderMock) AddSequenceProtocol ¶ added in v1.1.0
func (sequenceProtocolAdderMock *SequenceProtocolAdderMock) AddSequenceProtocol( r *test.SequenceExecutionProtocol) error
AddSequenceProtocol mocks adding a sequence protocol to the store
type SequenceProtocolListerMock ¶ added in v1.0.0
type SequenceProtocolListerMock struct { CallerMock Protocols []test.SequenceExecutionProtocol Err error // contains filtered or unexported fields }
SequenceProtocolListerMock mocks the SequenceProtocolLister
func (*SequenceProtocolListerMock) GetSequenceExecutionProtocols ¶ added in v1.0.0
func (m *SequenceProtocolListerMock) GetSequenceExecutionProtocols(sequenceID id.TestID) ( []test.SequenceExecutionProtocol, error, )
GetSequenceExecutionProtocols mocks retrieving protocols of a sequence
type SequenceRenameHandler ¶ added in v1.0.0
type SequenceRenameHandler interface { // HandlerSequenceRename allows dependents to handle renames of test sequences HandleSequenceRename(old, new id.TestID) error }
SequenceRenameHandler defines an interface clients need to fulfill to handle renames of test sequences
type SequenceRenameHandlerMock ¶ added in v1.0.0
type SequenceRenameHandlerMock struct { CallerMock // contains filtered or unexported fields }
SequenceRenameHandlerMock mocks the SequenceRenameHandler
func (*SequenceRenameHandlerMock) HandleSequenceRename ¶ added in v1.0.0
func (srh *SequenceRenameHandlerMock) HandleSequenceRename(old, new id.TestID) error
HandleSequenceRename mocks renaming a sequence
type SequenceRenamerMock ¶ added in v1.0.0
type SequenceRenamerMock struct { CallerMock // contains filtered or unexported fields }
SequenceRenamerMock mocks the SequenceRenamer
type SequenceSessionGetterMock ¶ added in v1.1.0
type SequenceSessionGetterMock struct { CallerMock SeqExecProtocol *test.SequenceExecutionProtocol }
SequenceSessionGetterMock mocks the SequenceSessionGetter interface
func (*SequenceSessionGetterMock) GetCurrentSequenceProtocol ¶ added in v1.1.0
func (ssgm *SequenceSessionGetterMock) GetCurrentSequenceProtocol(r *http.Request) (*test.SequenceExecutionProtocol, error)
GetCurrentSequenceProtocol mocks getting the current sequence protocol
type SequenceSessionMock ¶ added in v1.1.0
type SequenceSessionMock struct { CallerMock SequenceSessionGetterMock SequenceSessionSetterMock TimeSessionMock Err error }
SequenceSessionMock mocks the SequenceSession interface
func (*SequenceSessionMock) RemoveCurrentSequenceProtocol ¶ added in v1.1.0
func (sequenceSessionMock *SequenceSessionMock) RemoveCurrentSequenceProtocol(w http.ResponseWriter, r *http.Request) error
RemoveCurrentSequenceProtocol mocks removing the current sequence protocol from the session
type SequenceSessionSetterMock ¶ added in v1.1.0
type SequenceSessionSetterMock struct { CallerMock Err error }
SequenceSessionSetterMock mocks the SequenceSessionSetter interface
func (*SequenceSessionSetterMock) SetCurrentSequenceProtocol ¶ added in v1.1.0
func (sequenceSessionSetterMock *SequenceSessionSetterMock) SetCurrentSequenceProtocol(w http.ResponseWriter, r *http.Request, protocol *test.SequenceExecutionProtocol) error
SetCurrentSequenceProtocol mocks setting the current sequence protocol
type SequenceUpdaterMock ¶ added in v1.0.0
type SequenceUpdaterMock struct { SequenceAdderMock SequenceRenamerMock SequenceDeletionMock }
SequenceUpdaterMock mocks the SequenceUpdater
type TestCaseAdder ¶ added in v0.8.0
type TestCaseAdder interface { // Add stores a test case for the given project under the given container Add(testCase *test.Case) error }
TestCaseAdder provides everything needed to add a testcase to a storage.
type TestCaseDeleter ¶ added in v0.8.0
type TestCaseDeleter interface { // Delete removes the test case with the given ID for the given project under the given container Delete(caseID id.TestID) error }
TestCaseDeleter provides everything needed to remove a testcase to a storage.
type TestCaseGetter ¶ added in v0.8.0
type TestCaseGetter interface { // Get returns the test case with the given ID for the given project under the given container Get(caseID id.TestID) (*test.Case, bool, error) }
TestCaseGetter is used to get testcases from the store.
type TestCaseLister ¶ added in v0.8.0
type TestCaseLister interface { // List returns a list of test cases for the given project under the given container List(projectID id.ProjectID) ([]*test.Case, error) }
TestCaseLister is used to list all testcases for a specific project.
type TestCaseProtocolLister ¶ added in v0.10.0
type TestCaseProtocolLister interface { // GetCaseExecutionProtocols gets the protocols for the testcase with given id, // which is part of the project with given id. GetCaseExecutionProtocols(testCaseID id.TestID) ([]test.CaseExecutionProtocol, error) }
TestCaseProtocolLister is used to list testcase execution protocols.
type TestCaseRenamer ¶ added in v1.0.0
type TestCaseRenamer interface { // Rename changes the name of a given test case to the new name Rename(old, new id.TestID) error }
TestCaseRenamer provides a function for renaming a test case
type TestCaseUpdater ¶ added in v0.8.0
type TestCaseUpdater interface { TestCaseDeleter TestCaseAdder TestCaseRenamer }
TestCaseUpdater contains every method needed to update a testcase.
type TestExistenceCheckerMock ¶ added in v1.0.0
type TestExistenceCheckerMock struct { CallerMock CaseID id.TestID }
TestExistenceCheckerMock mocks the TestExistenceChecker
type TestHandler ¶
type TestHandler interface { // Name returned the name of the test. Name() string // Tested returns the handler that will be tested. Tested() http.HandlerFunc // Requests returns the request that will be send to the // handler during the test. Requests() []*http.Request // Checks returns a number of checks that need to be performed // on the response the handler gave during the test. Checks() []ResponseMatcher // SetUp prepared the test. SetUp() }
TestHandler is a simple test for a handler.
func CreateTest ¶ added in v1.0.0
func CreateTest(name string, setUp TestSetUp, rs ...*http.Request) TestHandler
CreateTest is used to create a simple test for a handler.
type TestSequenceAdder ¶ added in v0.8.0
type TestSequenceAdder interface { // Add stores a test sequence for the given project under the given container Add(testSequence *test.Sequence) error }
TestSequenceAdder is used to add testsequences to the storage.
type TestSequenceDeleter ¶ added in v0.8.0
type TestSequenceDeleter interface { // Delete removes the testsequence with the given ID for the given project under the given container Delete(sequenceID id.TestID) error }
TestSequenceDeleter is used to delete testsequences from the storage.
type TestSequenceLister ¶ added in v0.8.0
type TestSequenceLister interface { // List returns a list of test sequences for the given project under the given container List(projectID id.ProjectID) ([]*test.Sequence, error) }
TestSequenceLister is used to list all testsequences for a specific project.
type TestSequenceProtocolLister ¶ added in v0.10.0
type TestSequenceProtocolLister interface { // GetSequenceExecutionProtocols gets the protocols for the testsequence with given id, // which is part of the project with given id. GetSequenceExecutionProtocols(sequenceID id.TestID) ([]test.SequenceExecutionProtocol, error) }
TestSequenceProtocolLister is used to list testsequence execution protocols.
type TestSequenceRenamer ¶ added in v1.0.0
type TestSequenceRenamer interface { // Rename changes the name of a given test sequence to the new name Rename(old, new id.TestID) error }
TestSequenceRenamer provides a function for renaming a test case
type TestSequenceUpdater ¶ added in v0.8.0
type TestSequenceUpdater interface { TestSequenceAdder TestSequenceRenamer TestSequenceDeleter }
TestSequenceUpdater is used to update testsequences in the storage.
type TestSetUp ¶ added in v1.0.0
type TestSetUp func() (http.HandlerFunc, []ResponseMatcher)
TestSetUp sets up a test by creating the tested handler and matchers that need to be fulfilled by the response the handler gives.
func ExpectResponse ¶ added in v1.0.0
func ExpectResponse(tested http.HandlerFunc, matchers ...ResponseMatcher) TestSetUp
ExpectResponse is a simple setup method that can be used if there is no shared data between the matchers and the handler itself.
type TimeSessionMock ¶ added in v1.1.0
type TimeSessionMock struct { CallerMock Duration *duration.Duration Err error }
TimeSessionMock mocks the TimeSession interface
func (*TimeSessionMock) GetDuration ¶ added in v1.1.0
GetDuration mocks getting the duration from the session
func (*TimeSessionMock) SetDuration ¶ added in v1.1.0
func (tsm *TimeSessionMock) SetDuration(w http.ResponseWriter, r *http.Request, duration *duration.Duration) error
SetDuration mocks setting the duration
type UserLister ¶ added in v0.8.0
type UserLister interface { // List returns a list of users in the system List() ([]*user.User, error) }
UserLister is used to list all users in the system.
type UserListerMock ¶ added in v1.0.0
type UserListerMock struct { CallerMock Users []*user.User Err error }
UserListerMock mocks the UserLister
type UserRetrieverMock ¶ added in v1.1.0
type UserRetrieverMock struct { CallerMock User *user.User UserFound bool Err error }
UserRetrieverMock mocks the UserRetriever interface
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package assignment handles the assigning of tests to users.
|
Package assignment handles the assigning of tests to users. |
Package creation contains the logic to create or add elements.
|
Package creation contains the logic to create or add elements. |
Package deletion contains the logic for deleting or removing elements.
|
Package deletion contains the logic for deleting or removing elements. |
Package display contains the logic for showing the templates for entities of the system, e.g.
|
Package display contains the logic for showing the templates for entities of the system, e.g. |
Package duplication handles duplicating elements (e.g.
|
Package duplication handles duplicating elements (e.g. |
Package execution handles the execution of cases and sequences.
|
Package execution handles the execution of cases and sequences. |
Package json contains functions to serve and receive data as json.
|
Package json contains functions to serve and receive data as json. |
Package list contains the logic for listing elements and everything that comes with listing, like filtering, sorting, etc.
|
Package list contains the logic for listing elements and everything that comes with listing, like filtering, sorting, etc. |
Package printing contains the logic for printing elements of the system.
|
Package printing contains the logic for printing elements of the system. |
Package update contains the logic for updating elements in the system (cases/sequences/projects...).
|
Package update contains the logic for updating elements in the system (cases/sequences/projects...). |
Package usersession contains the logic for usersession handling.
|
Package usersession contains the logic for usersession handling. |