handler

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2019 License: GPL-3.0 Imports: 40 Imported by: 0

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

View Source
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

View Source
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

View Source
var DummyGroup = &group.Group{
	Name:        "Dummy Group Name",
	Description: "Desc",
	Visibility:  visibility.Public,
}

DummyGroup is a group for testing purposes

View Source
var DummyMembership = &project.UserMembership{
	User:        "acc_name",
	Role:        "Owner",
	MemberSince: time.Now().UTC().Round(time.Second),
}

DummyMembership represents a membership that is used for testing purposes The user has the role "Owner" so he ca

View Source
var DummyProject = &project.Project{
	Name:        "DuckDuckGo.com",
	Description: "Test the online search engine DuckDuckGo.com",
	Visibility:  visibility.Public,
	Owner:       "default",
	Token:       "token",
	Versions: map[string]*project.Version{
		"Chrome": {
			Name: "Chrome",
			Variants: []project.Variant{
				0: {Name: "1.0.1"},
				1: {Name: "2.0.1"},
				2: {Name: "3.0.5"},
			},
		},
		"Firefox": {
			Name: "Firefox",
			Variants: []project.Variant{
				0: {Name: "1.0.1"},
				1: {Name: "2.0.1"},
				2: {Name: "3.0.5"},
			},
		},
		"Microsoft Edge": {
			Name: "Microsoft Edge",
			Variants: []project.Variant{
				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

View Source
var DummyProjectInternal = &project.Project{
	Name:        "DuckDuckGo.com",
	Description: "Test the online search engine DuckDuckGo.com",
	Visibility:  visibility.Internal,
	Owner:       "default",
	Versions: map[string]*project.Version{
		"Chrome": {
			Name: "Chrome",
			Variants: []project.Variant{
				0: {Name: "1.0.1"},
				1: {Name: "2.0.1"},
				2: {Name: "3.0.5"},
			},
		},
		"Firefox": {
			Name: "Firefox",
			Variants: []project.Variant{
				0: {Name: "1.0.1"},
				1: {Name: "2.0.1"},
				2: {Name: "3.0.5"},
			},
		},
		"Microsoft Edge": {
			Name: "Microsoft Edge",
			Variants: []project.Variant{
				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

View Source
var DummyProjectPrivate = &project.Project{
	Name:        "DuckDuckGo.com",
	Description: "Test the online search engine DuckDuckGo.com",
	Visibility:  visibility.Private,
	Owner:       "default",
	Versions: map[string]*project.Version{
		"Chrome": {
			Name: "Chrome",
			Variants: []project.Variant{
				0: {Name: "1.0.1"},
				1: {Name: "2.0.1"},
				2: {Name: "3.0.5"},
			},
		},
		"Firefox": {
			Name: "Firefox",
			Variants: []project.Variant{
				0: {Name: "1.0.1"},
				1: {Name: "2.0.1"},
				2: {Name: "3.0.5"},
			},
		},
		"Microsoft Edge": {
			Name: "Microsoft Edge",
			Variants: []project.Variant{
				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

View Source
var DummyRoles = map[project.RoleName]*project.Role{
	"Owner": {
		Name: "Owner",
		Permissions: project.Permissions{
			project.DisplayPermissions{
				DisplayProject: true,
			},
			project.ExecutionPermissions{
				Execute: true,
			},
			project.CasePermissions{
				CreateCase:    true,
				EditCase:      true,
				DeleteCase:    true,
				AssignCase:    true,
				DuplicateCase: true,
			},
			project.SequencePermissions{
				CreateSequence:    true,
				EditSequence:      true,
				DeleteSequence:    true,
				AssignSequence:    true,
				DuplicateSequence: true,
			},
			project.MemberPermissions{
				EditMembers: true,
			},
			project.SettingsPermissions{
				EditProject:     true,
				DeleteProject:   true,
				EditPermissions: true,
			},
		},
	},
	"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

View Source
var DummyTestCase = &test.Case{
	Name: "Test Case 1",
	TestCaseVersions: []test.CaseVersion{
		{
			VersionNr:   1,
			Description: "First Test Case",
			Versions:    map[string]*project.Version{},
			Preconditions: []test.Precondition{
				test.Precondition{
					Id:          1,
					TestVersion: 1,
					Content:     "Test",
				},
			},
			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

View Source
var DummyTestCaseExecutionProtocol = &test.CaseExecutionProtocol{
	TestVersion: id.NewTestVersionID(DummyTestCase.TestCaseVersions[0].ID().TestID, 1),
	ProtocolNr:  1,

	SUTVersion: "Desktop",
	SUTVariant: "v1018",

	ExecutionDate: time.Now().UTC().Round(time.Second),

	StepProtocols: []test.StepExecutionProtocol{
		{
			ObservedBehavior: "The search results are viewed.",
			Result:           test.Pass,
			NeededTime:       duration.NewDuration(0, 5, 0),
		},
		{
			ObservedBehavior: "The sidebar opens.",
			Result:           test.Pass,
			NeededTime:       duration.NewDuration(0, 5, 0),
		},
		{
			ObservedBehavior: "The icons didn't disappear.",
			Result:           test.Fail,
			NeededTime:       duration.NewDuration(0, 5, 0),
		},
	},

	Result:          test.Fail,
	OtherNeededTime: duration.NewDuration(0, 5, 0),
}
View Source
var DummyTestCaseSUTVersions = &test.Case{
	Name: "Test Case 1",
	TestCaseVersions: []test.CaseVersion{
		{
			Description: "First Test Case",
			Versions: map[string]*project.Version{
				"Chrome": {
					Name: "Chrome",
					Variants: []project.Variant{
						0: {Name: "1.0.1"},
						1: {Name: "2.0.1"},
						2: {Name: "3.0.5"},
					},
				},
				"Firefox": {
					Name: "Firefox",
					Variants: []project.Variant{
						0: {Name: "1.0.1"},
						1: {Name: "2.0.1"},
						2: {Name: "3.0.5"},
					},
				},
				"Microsoft Edge": {
					Name: "Microsoft Edge",
					Variants: []project.Variant{
						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

View Source
var DummyTestSequence = &test.Sequence{
	Name:   "test-sequence-1",
	Labels: []*project.Label{},
	SequenceVersions: []test.SequenceVersion{
		dummyTestSequenceVersion,
	},
}

DummyTestSequence is a sequence for testing purposes

View Source
var DummyTestSequenceExecutionProtocol = &test.SequenceExecutionProtocol{
	TestVersion: id.NewTestVersionID(DummyTestSequence.SequenceVersions[0].ID().TestID, 1),
	ProtocolNr:  1,

	SUTVersion: "Desktop",
	SUTVariant: "v1018",

	CaseExecutionProtocols: []id.ProtocolID{
		{},
		{},
	},

	ExecutionDate: time.Now().UTC().Round(time.Second),
}
View Source
var DummyTestSequenceJSON string

DummyTestSequenceJSON is sequence in json for testing purposes

View Source
var DummyUser = &user.User{
	DisplayName:      "DisplayName",
	Name:             "acc_name",
	Email:            "test@example.com",
	RegistrationDate: time.Now().UTC().Round(time.Second),
	IsAdmin:          false,
	Biography:        "",
	IsShownPublic:    true,
	IsEmailPublic:    false,
	IsDeactivated:    false,
}

DummyUser is a user for testing purposes

View Source
var DummyUserUnauthorized = &user.User{
	DisplayName:      "DisplayName",
	Name:             "unauthorized",
	Email:            "un@authorized.com",
	RegistrationDate: time.Now().UTC().Round(time.Second),
	IsAdmin:          false,
	Biography:        "",
	IsShownPublic:    true,
	IsEmailPublic:    false,
	IsDeactivated:    false,
}

DummyUserUnauthorized is a user that is is not authorized to send requests because he is not a member of a project

View Source
var EmptyCtx = &testContext{make(map[interface{}]interface{})}

EmptyCtx is an empty context for testing purpses

View Source
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

View Source
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 Dict

func Dict(values ...interface{}) (map[string]interface{}, error)

func EmptyRequest added in v1.0.0

func EmptyRequest(method string) *http.Request

EmptyRequest creates a simple test request with no parameters and no context attached to it.

func GetBaseTree added in v1.0.0

func GetBaseTree(r *http.Request) templates.LoadedTemplate

GetBaseTree returns a loaded base template containing only utility function used by the templates.

func GetLatestTestCaseVersion added in v1.0.0

func GetLatestTestCaseVersion(r *http.Request, tc *test.Case) (*test.CaseVersion, error)

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(r *http.Request) templates.LoadedTemplate

GetNoSideBarTree returns a loaded template structure for a view not containing the sidebar.

func GetPrintTree added in v1.0.0

func GetPrintTree(r *http.Request) templates.LoadedTemplate

GetPrintTree returns a loaded template structure for a print view .

func GetSideBarTree added in v1.0.0

func GetSideBarTree(r *http.Request) templates.LoadedTemplate

GetSideBarTree returns a loaded template structure for a view containing the sidebar.

func GetTestCaseVersion added in v1.0.0

func GetTestCaseVersion(r *http.Request, tc *test.Case) (*test.CaseVersion, error)

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

func GetTestCases(tg TestCaseGetter, ids ...id.TestID) ([]test.Case, error)

GetTestCases returns the testcase objects of the given ids

func GetTestSequenceVersion added in v1.0.0

func GetTestSequenceVersion(r *http.Request, ts *test.Sequence) (*test.SequenceVersion, error)

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

func GetVersion(r *http.Request, defaultVersion int) int

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 NewHeaderRequest added in v1.7.0

func NewHeaderRequest(ctx context.Context, method string, header map[string][]string, body string) *http.Request

NewHeaderRequest is used to create a request for testing with a header and a body

func NewRequest added in v1.0.0

func NewRequest(ctx context.Context, method string, params url.Values, body string) *http.Request

NewRequest is used to create a request for testing.

func PrintTmpl added in v1.0.0

func PrintTmpl(ctx context.Context, template *template.Template, w io.Writer, r *http.Request)

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

func SimpleContext(values map[interface{}]interface{}) context.Context

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

func SimpleFragmentRequest(ctx context.Context, method string, params url.Values) *http.Request

SimpleFragmentRequest is used to create a simple request for testing.

func SimpleRequest added in v1.0.0

func SimpleRequest(ctx context.Context, method string, params url.Values) *http.Request

SimpleRequest is used to create a simple request for testing.

func StringToBool

func StringToBool(s string) (bool, error)

StringToBool converts a string to a bool value. Returns the value and an error if the string is not valid.

func StringToInt added in v1.0.0

func StringToInt(s string) int

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 Activities

type Activities interface {
	LogActivity(activityType int, activityEntities *activity.ActivityEntities, request *http.Request) error
	GetActivitiesForProjectLimitFromOffset(projectId int64, limit int, offset int) ([]*activity.Activity, error)
}

type ActivityMock

type ActivityMock struct {
	CallerMock
}

func (ActivityMock) GetActivitiesForProjectLimitFromOffset

func (ActivityLoggerMock ActivityMock) GetActivitiesForProjectLimitFromOffset(projectId int64, limit int, offset int) ([]*activity.Activity, error)

func (ActivityMock) LogActivity

func (activityLoggerMock ActivityMock) LogActivity(activityType int, entities *activity.ActivityEntities, request *http.Request) error

type ActorExistenceCheckerMock added in v1.0.0

type ActorExistenceCheckerMock struct {
	CallerMock

	Exst bool
	// contains filtered or unexported fields
}

ActorExistenceCheckerMock mocks the ActorExistenceChecker

func (*ActorExistenceCheckerMock) Exists added in v1.0.0

func (m *ActorExistenceCheckerMock) Exists(id id.ActorID) (bool, error)

Exists mocks checking for the existence of an actor

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

func NewAuthMock(returnedUser *user.User, returnedError error, accept bool) *AuthMock

NewAuthMock creates a new Auth mock

func (*AuthMock) Validate added in v1.0.0

func (a *AuthMock) Validate(identifier string, password string) (*user.User, bool, error)

Validate is a mock method

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

func (*CaseAdderMock) Add added in v1.0.0

func (m *CaseAdderMock) Add(testCase *test.Case) error

Add mocks adding a case to the store

type CaseDeleterMock added in v1.0.0

type CaseDeleterMock struct {
	CallerMock
	id.TestID
}

CaseDeleterMock mocks the CaseDeleter

func (*CaseDeleterMock) Delete added in v1.0.0

func (m *CaseDeleterMock) Delete(testCase *test.Case) error

Delete mocks deleting a case from the store

type CaseGetterMock added in v1.0.0

type CaseGetterMock struct {
	CallerMock
	CaseID id.TestID
}

CaseGetterMock mocks the CaseGetter

func (*CaseGetterMock) Get added in v1.0.0

func (m *CaseGetterMock) Get(caseID id.TestID) (*test.Case, bool, error)

Get mocks the retrieval of a case from a test id

type CaseListerMock added in v1.0.0

type CaseListerMock struct {
	CallerMock
	Project  id.ProjectID
	CaseList []*test.Case
	Err      error
}

CaseListerMock mocks the CaseLister

func (*CaseListerMock) List added in v1.0.0

func (m *CaseListerMock) List(projectID id.ProjectID) ([]*test.Case, error)

List mocks listing cases

type CaseProtocolAdderMock added in v1.1.0

type CaseProtocolAdderMock struct {
	CallerMock
	CaseExecutionProtocol test.CaseExecutionProtocol
	Err                   error
	CaseVersion           test.CaseVersion
}

CaseProtocolAdderMock mocks the CaseProtocolAdder interface

func (*CaseProtocolAdderMock) AddCaseProtocol added in v1.1.0

func (caseProtocolAdderMock *CaseProtocolAdderMock) AddCaseProtocol(r *test.CaseExecutionProtocol, caseVersion test.CaseVersion) (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 CaseProtocolLister added in v1.4.0

type CaseProtocolLister 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)
	GetCaseExecutionProtocolsForProject(projectID id.ProjectID) ([]test.CaseExecutionProtocol, error)
	GetCaseExecutionProtocol(protocolID id.ProtocolID) (test.CaseExecutionProtocol, error)
}

CaseProtocolLister is used to list testcase execution protocols.

type CaseProtocolListerMock added in v1.0.0

type CaseProtocolListerMock struct {
	CallerMock

	Protocols []test.CaseExecutionProtocol
	Protocol  test.CaseExecutionProtocol
	Err       error
	// contains filtered or unexported fields
}

CaseProtocolListerMock mocks the CaseProtocolsLister

func (*CaseProtocolListerMock) GetCaseExecutionProtocol added in v1.3.0

func (m *CaseProtocolListerMock) GetCaseExecutionProtocol(protocolID id.ProtocolID) (test.CaseExecutionProtocol, error)

GetCaseExecutionProtocol mocks retrieving protocol of a protocolID

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

func (*CaseProtocolListerMock) GetCaseExecutionProtocolsForProject added in v1.5.0

func (m *CaseProtocolListerMock) GetCaseExecutionProtocolsForProject(projectID id.ProjectID) ([]test.CaseExecutionProtocol, error)

GetCaseExecutionProtocols mocks retrieving protocols of a case for a project

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

func (*CaseProtocolStoreMock) GetCaseExecutionProtocolsForProject added in v1.7.0

func (caseProtocolStoreMock *CaseProtocolStoreMock) GetCaseExecutionProtocolsForProject(projectID id.ProjectID) (
	[]test.CaseExecutionProtocol, error)

type CaseRenamerMock added in v1.0.0

type CaseRenamerMock struct {
	CallerMock
	Old id.TestID
	New id.TestID
}

CaseRenamerMock mocks the CaseRenamer

func (*CaseRenamerMock) Rename added in v1.0.0

func (m *CaseRenamerMock) Rename(old, new id.TestID) error

Rename mocks the renaming of a test

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 {
	InsertComment(comment *comment.Comment, testObject interface{}, user *user.User) error
}

CommentAdder is required to use the comment store from the display-handler package. Do not delete this.

type CommentAdderMock added in v1.0.0

type CommentAdderMock struct {
	// contains filtered or unexported fields
}

func (CommentAdderMock) Calls added in v1.7.0

func (adderMock CommentAdderMock) Calls() int

func (CommentAdderMock) InsertComment added in v1.7.0

func (adderMock CommentAdderMock) InsertComment(comment *comment.Comment, testObject interface{}, user *user.User) error

func (CommentAdderMock) UpdateComment added in v1.7.0

func (adderMock CommentAdderMock) UpdateComment(*comment.Comment) error

type CommentDeleterMock added in v1.7.0

type CommentDeleterMock struct {
	// contains filtered or unexported fields
}

func (CommentDeleterMock) Calls added in v1.7.0

func (deleterMock CommentDeleterMock) Calls() int

func (CommentDeleterMock) DeleteCommentsForTest added in v1.7.0

func (deleterMock CommentDeleterMock) DeleteCommentsForTest(testObject interface{}) error

type CommentGetterMock added in v1.7.0

type CommentGetterMock struct {
	// contains filtered or unexported fields
}

func (CommentGetterMock) Calls added in v1.7.0

func (getterMock CommentGetterMock) Calls() int

func (CommentGetterMock) GetComment added in v1.7.0

func (getterMock CommentGetterMock) GetComment(commentId int64, project *project.Project) (*comment.Comment, error)

func (CommentGetterMock) GetCommentsForTest added in v1.7.0

func (getterMock CommentGetterMock) GetCommentsForTest(testObject interface{}, project *project.Project, requester *user.User) ([]*comment.Comment, error)

type CommentStoreMock added in v1.7.0

type CommentStoreMock struct {
	CommentAdderMock
	CommentGetterMock
	CommentDeleterMock
	Err error
}

type Comments added in v1.7.0

type Comments interface {
	GetComment(commentId int64, project *project.Project) (*comment.Comment, error)
	UpdateComment(*comment.Comment) error
	CommentAdder
	GetCommentsForTest(testObject interface{}, project *project.Project, requester *user.User) ([]*comment.Comment, error)
	DeleteCommentsForTest(testObject interface{}) error
}

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
	CaseProtocol     *test.CaseExecutionProtocol
	SequenceProtocol *test.SequenceExecutionProtocol
	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.

func (ContextEntities) GetActivityEntities

func (contextEntities ContextEntities) GetActivityEntities() *activity.ActivityEntities

Do to circular dependencies, we have to pass the contextEntities in the struct format "ActivityEntities"

type GroupAdder added in v0.8.0

type GroupAdder interface {
	// Add stores a group in the system
	Add(group *group.Group) error
}

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

func (*GroupAdderMock) Add added in v1.0.0

func (m *GroupAdderMock) Add(group *group.Group) error

Add mocks adding a group to the store

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

func (*GroupListerMock) List added in v1.0.0

func (m *GroupListerMock) List() ([]*group.Group, error)

List mocks listing groups

type IssueAdder

type IssueAdder interface {
	AddIssue(issue integration.GitLabIssue) error
}

type IssueAdderMock

type IssueAdderMock struct {
	CallerMock
	Err error
}

func (*IssueAdderMock) AddIssue

func (issueAdderMock *IssueAdderMock) AddIssue(issue integration.GitLabIssue) error

type IssueGetter

type IssueGetter interface {
	GetIssue(testCaseID id.TestID, version string, variant string) (*integration.GitLabIssue, error)
}

type IssueGetterMock

type IssueGetterMock struct {
	CallerMock
	Issue *integration.GitLabIssue
}

func (*IssueGetterMock) GetIssue

func (issueGetterMock *IssueGetterMock) GetIssue(testCaseID id.TestID, version string, variant string) (*integration.GitLabIssue, error)

type LabelStoreMock

type LabelStoreMock struct {
	CallerMock
	Err error
}

func (LabelStoreMock) Calls

func (labelStoreMock LabelStoreMock) Calls() int

func (LabelStoreMock) DeleteLabel

func (labelStoreMock LabelStoreMock) DeleteLabel(labelId int64) error

func (LabelStoreMock) DeleteTestLabel

func (labelStoreMock LabelStoreMock) DeleteTestLabel(labelId int64, testId int64, projectId int64, isCase bool) error

func (LabelStoreMock) GetAllTestLabels

func (labelStoreMock LabelStoreMock) GetAllTestLabels() ([]*project.TestLabel, error)

func (LabelStoreMock) GetLabelsForProject

func (labelStoreMock LabelStoreMock) GetLabelsForProject(testProject *project.Project) ([]*project.Label, error)

func (LabelStoreMock) GetLabelsForTest

func (labelStoreMock LabelStoreMock) GetLabelsForTest(testObject interface{}, projectId int64) ([]*project.Label, error)

func (LabelStoreMock) InsertTestLabel

func (labelStoreMock LabelStoreMock) InsertTestLabel(labelId int64, testId int64, projectId int64, isCase bool) error

func (LabelStoreMock) UpdateLabelForProject

func (labelStoreMock LabelStoreMock) UpdateLabelForProject(label *project.Label, projectId int64) (int64, error)

type Labels

type Labels interface {
	GetLabelsForProject(testProject *project.Project) ([]*project.Label, error)
	DeleteLabel(labelId int64) error
	UpdateLabelForProject(label *project.Label, projectId int64) (int64, error)

	GetLabelsForTest(testObject interface{}, projectId int64) ([]*project.Label, error)
	DeleteTestLabel(labelId int64, testId int64, projectId int64, isCase bool) error
	InsertTestLabel(labelId int64, testId int64, projectId int64, isCase bool) error
	GetAllTestLabels() ([]*project.TestLabel, error)
}

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

func (*ProjectAdderMock) Add added in v1.0.0

func (p *ProjectAdderMock) Add(pr *project.Project) error

Add mocks adding a project to the store

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

func (*ProjectDeleterMock) Delete added in v1.0.0

func (m *ProjectDeleterMock) Delete(projectID id.ProjectID) error

Delete mocks deleting a project from the store

type ProjectExistenceMock added in v1.0.0

type ProjectExistenceMock struct {
	CallerMock
	id.ProjectID
	Exst bool
}

ProjectExistenceMock mocks the ProjectExistenceChecker

func (*ProjectExistenceMock) Exists added in v1.0.0

func (m *ProjectExistenceMock) Exists(id id.ProjectID) (bool, error)

Exists mocks checking for the existence of a project

type ProjectLabelRenamer added in v1.7.0

type ProjectLabelRenamer interface {
	RenameProjectLabel(*project.Project, project.Label, project.Label) error
}

type ProjectLabelUpdater added in v1.7.0

type ProjectLabelUpdater interface {
	ProjectAdder
	ProjectLabelRenamer
}

type ProjectLister added in v0.8.0

type ProjectLister interface {
	// 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) 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

func (m *ProjectListerMock) ListForActor(actor id.ActorID) ([]*project.Project, error)

ListForActor mocks listing all projects that the actor has access to

func (*ProjectListerMock) ListForMember added in v1.1.0

func (m *ProjectListerMock) ListForMember(owner id.ActorID) ([]*project.Project, error)

ListForMember mocks listing projects where the actor is a member

func (*ProjectListerMock) ListForOwner added in v1.1.0

func (m *ProjectListerMock) ListForOwner(owner id.ActorID) ([]*project.Project, error)

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

func (m *ProjectListerMock) ListPrivate(actor id.ActorID) ([]*project.Project, error)

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 ProjectRoleAdder added in v1.4.0

type ProjectRoleAdder interface {
	Add(role *project.Role) error
}

type ProjectRoleDeleter added in v1.4.0

type ProjectRoleDeleter interface {
	Delete(role *project.Role) error
}

type ProjectRoleLister added in v1.4.0

type ProjectRoleLister interface {
	// List returns a list of roles for the given project under the given container
	List(projectID id.ProjectID) ([]*project.Role, error)
}

ProjectRoleLister is used to list all roles for a specific project.

type ProjectRoleUpdater added in v1.4.0

type ProjectRoleUpdater interface {
	ProjectRoleAdder
	ProjectRoleDeleter
}

type ProjectSUTVersionUpdater

type ProjectSUTVersionUpdater interface {
	ProjectAdder
	ProjectVersionRenamer
	ProjectVariantRenamer
}

type ProjectVariantRenamer

type ProjectVariantRenamer interface {
	RenameProjectVariant(project *project.Project, versionName, oldVariantName, newVariantName string) error
}

type ProjectVariantRenamerMock

type ProjectVariantRenamerMock struct {
	CallerMock
	*project.Project
	VersionName string

	Err error
	// contains filtered or unexported fields
}

func (*ProjectVariantRenamerMock) RenameProjectVariant

func (p *ProjectVariantRenamerMock) RenameProjectVariant(project *project.Project, VersionName, oldVariantName, newVariantName string) error

type ProjectVersionRenamer

type ProjectVersionRenamer interface {
	RenameProjectVersion(project *project.Project, oldVersionName, newVersionName string) error
}

type ProjectVersionRenamerMock

type ProjectVersionRenamerMock struct {
	CallerMock
	*project.Project

	Err error
	// contains filtered or unexported fields
}

func (*ProjectVersionRenamerMock) RenameProjectVersion

func (p *ProjectVersionRenamerMock) RenameProjectVersion(project *project.Project, oldVersionName, newVersionName string) error

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

	Protocols []test.CaseExecutionProtocol
	Protocol  test.CaseExecutionProtocol
	Err       error
	// contains filtered or unexported fields
}

ProtocolListerMock mocks the ProtocolLister interface

func (*ProtocolListerMock) GetCaseExecutionProtocol added in v1.5.0

func (m *ProtocolListerMock) GetCaseExecutionProtocol(protocolID id.ProtocolID) (test.CaseExecutionProtocol, error)

GetCaseExecutionProtocol mocks retrieving protocol of a protocolID

func (*ProtocolListerMock) GetCaseExecutionProtocols added in v1.5.0

func (m *ProtocolListerMock) GetCaseExecutionProtocols(testCaseID id.TestID) ([]test.CaseExecutionProtocol, error)

GetCaseExecutionProtocols mocks retrieving protocols of a case

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

Add mocks adding a user to the store

func (*RegisterServerMock) Get added in v1.0.0

func (usm *RegisterServerMock) Get(id id.ActorID) (*user.User, bool, error)

Get mocks the retrieval of the user from a given id

func (*RegisterServerMock) GetByMail added in v1.0.0

func (usm *RegisterServerMock) GetByMail(mail string) (*user.User, bool, error)

GetByMail mocks the retrieval of the user from a given mail

type ResponseMatcher added in v1.0.0

type ResponseMatcher func(t *testing.T, r *http.Response)

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

func (*SequenceAdderMock) Add added in v1.0.0

func (m *SequenceAdderMock) Add(testSequence *test.Sequence) error

Add mocks adding a sequence to the store

type SequenceDeletionMock added in v1.0.0

type SequenceDeletionMock struct {
	CallerMock
	ID id.TestID
}

SequenceDeletionMock mocks the SequenceDeleter

func (*SequenceDeletionMock) Delete added in v1.0.0

func (m *SequenceDeletionMock) Delete(testSequence *test.Sequence) error

Delete mocks deleting a sequence from the store

type SequenceListerMock added in v1.0.0

type SequenceListerMock struct {
	CallerMock
	Project id.ProjectID
	Err     error
}

SequenceListerMock mocks the SequenceLister

func (*SequenceListerMock) List added in v1.0.0

func (m *SequenceListerMock) List(projectID id.ProjectID) ([]*test.Sequence, error)

List mocks listing sequences

type SequenceProtocolAdderMock added in v1.1.0

type SequenceProtocolAdderMock struct {
	CallerMock
	SequenceExecutionProtocol *test.SequenceExecutionProtocol
	SequenceVersion           test.SequenceVersion
	Err                       error
}

SequenceProtocolAdderMock mocks the SequenceProtocolAdder interface

func (*SequenceProtocolAdderMock) AddSequenceProtocol added in v1.1.0

func (sequenceProtocolAdderMock *SequenceProtocolAdderMock) AddSequenceProtocol(
	r *test.SequenceExecutionProtocol, sequenceVersion test.SequenceVersion) error

AddSequenceProtocol mocks adding a sequence protocol to the store

type SequenceProtocolLister added in v1.4.0

type SequenceProtocolLister 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)
	GetSequenceExecutionProtocolsForProject(projectID id.ProjectID) ([]test.SequenceExecutionProtocol, error)
	// GetSequenceExecutionProtocol gets the protocol with the given id for the testsequence with given id,
	// which is part of the project with given id.
	GetSequenceExecutionProtocol(protocolID id.ProtocolID) (test.SequenceExecutionProtocol, error)
}

SequenceProtocolLister is used to list testsequence execution protocols.

type SequenceProtocolListerMock added in v1.0.0

type SequenceProtocolListerMock struct {
	CallerMock

	Protocols []test.SequenceExecutionProtocol
	Protocol  test.SequenceExecutionProtocol
	Err       error
	// contains filtered or unexported fields
}

SequenceProtocolListerMock mocks the SequenceProtocolLister

func (*SequenceProtocolListerMock) GetSequenceExecutionProtocol added in v1.4.0

func (m *SequenceProtocolListerMock) GetSequenceExecutionProtocol(protocolID id.ProtocolID) (test.SequenceExecutionProtocol, error)

GetSequenceExecutionProtocol mocks retrieving a protocol of a sequence

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

func (*SequenceProtocolListerMock) GetSequenceExecutionProtocolsForProject added in v1.5.0

func (m *SequenceProtocolListerMock) GetSequenceExecutionProtocolsForProject(projectID id.ProjectID) ([]test.SequenceExecutionProtocol, error)

GetSequenceExecutionProtocols mocks retrieving protocols of a sequence for project

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

func (*SequenceRenamerMock) Rename added in v1.0.0

func (m *SequenceRenamerMock) Rename(old, new id.TestID) error

Rename mocks renaming a sequence

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

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 SystemSettings added in v1.7.0

type SystemSettings interface {
	GetSystemSettings() (*system.SystemSettings, error)
	UpdateSystemSettings(systemSettings *system.SystemSettings) error
	InsertSystemSettings(systemSettings *system.SystemSettings) error
}

type SystemSettingsAddMock added in v1.7.0

type SystemSettingsAddMock struct {
	CallerMock
}

func (SystemSettingsAddMock) Calls added in v1.7.0

func (systemSettingsAddMock SystemSettingsAddMock) Calls() int

func (SystemSettingsAddMock) InsertSystemSettings added in v1.7.0

func (systemSettingsAddMock SystemSettingsAddMock) InsertSystemSettings(systemSettings *system.SystemSettings) error

func (SystemSettingsAddMock) UpdateSystemSettings added in v1.7.0

func (systemSettingsAddMock SystemSettingsAddMock) UpdateSystemSettings(systemSettings *system.SystemSettings) error

type SystemSettingsGetMock added in v1.7.0

type SystemSettingsGetMock struct {
	CallerMock
}

func (SystemSettingsGetMock) Calls added in v1.7.0

func (systemSettingsGetMock SystemSettingsGetMock) Calls() int

func (SystemSettingsGetMock) GetSystemSettings added in v1.7.0

func (systemSettingsGetMock SystemSettingsGetMock) GetSystemSettings() (*system.SystemSettings, error)

type SystemSettingsStoreMock added in v1.7.0

type SystemSettingsStoreMock struct {
	SystemSettingsGetMock
	SystemSettingsAddMock
}

type TaskAdder

type TaskAdder interface {
	// AddItem saves an item to the store
	AddItem(item task.Item) error
}

TaskAdder is used to add tasks to the store

type TaskGetter

type TaskGetter interface {
	// GetTasksForTest retrieves the open tasks for a test, identified by the testID
	GetTasksForTest(testID id.TestID) ([]*task.Item, error)
}

TaskGetter is used to retrieve tasks

type TaskGetterMock

type TaskGetterMock struct {
	CallerMock
	TaskList *task.List
	Tasks    []*task.Item
}

TaskGetterMock mocks the TaskGetter

func (TaskGetterMock) GetTasksForTest

func (mock TaskGetterMock) GetTasksForTest(testID id.TestID) ([]*task.Item, error)

GetTasksForTest mocks getting tasks for the given tests

type TaskListAdder added in v1.7.0

type TaskListAdder interface {
	// Add saves a to do-list to the system
	Add(list task.List) error
}

TaskListAdder is used to add a to do list to the storage

type TaskListAdderMock added in v1.7.0

type TaskListAdderMock struct {
	CallerMock
	TaskList task.List
	Err      error
}

TaskListAdderMock mocks the TaskListAdder interface

func (TaskListAdderMock) Add added in v1.7.0

func (taskListAdderMock TaskListAdderMock) Add(taskList task.List) error

Add mocks adding a taskList to the store

type TaskListGetter added in v1.7.0

type TaskListGetter interface {
	// Get returns the to do-list of a user. If the user does not have one,
	// an empty list is returned
	Get(username string) (*task.List, error)
}

TaskListGetter is used to retrieve to do-lists from the store

type TaskListGetterMock added in v1.7.0

type TaskListGetterMock struct {
	CallerMock
	TaskList *task.List
	Username string
	Err      error
}

TaskListGetterMock mocks the TaskListGetter interface

func (TaskListGetterMock) Get added in v1.7.0

func (taskListGetterMock TaskListGetterMock) Get(username string) (*task.List, error)

Get mocks getting the to do-list for a user with the given username

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(testCase *test.Case) 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 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

func (*TestExistenceCheckerMock) Exists added in v1.0.0

func (m *TestExistenceCheckerMock) Exists(id id.TestID) (bool, error)

Exists mocks checking for the existence of a test

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(testSequence *test.Sequence) error
}

TestSequenceDeleter is used to delete testsequences from the storage.

type TestSequenceGetter added in v1.3.0

type TestSequenceGetter interface {
	Get(testId id.TestID) (*test.Sequence, bool, error)
}

TestSequenceGetter returns the test.Sequence for the testId

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 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 TestSequenceStoreMock added in v1.4.0

type TestSequenceStoreMock struct {
	Sequence test.Sequence
	Err      error
}

func (*TestSequenceStoreMock) Get added in v1.4.0

func (testSequenceStoreMock *TestSequenceStoreMock) Get(sequenceID id.TestID) (*test.Sequence, bool, error)

Mocked method that always returns valid results

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

func (tsm *TimeSessionMock) GetDuration(r *http.Request) (*duration.Duration, error)

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 UserAdder added in v1.7.0

type UserAdder interface {
	Add(pur *user.PasswordUser) error
}

UserAdder is used to add users

type UserAdderMock added in v1.7.0

type UserAdderMock struct {
	CallerMock
	Err error
}

func (*UserAdderMock) Add added in v1.7.0

func (m *UserAdderMock) Add(pur *user.PasswordUser) error

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

func (*UserListerMock) Initialize added in v1.7.0

func (m *UserListerMock) Initialize(users ...*user.User) error

Adds Users to the UserLister

func (*UserListerMock) List added in v1.0.0

func (m *UserListerMock) List() ([]*user.User, error)

List mocks listing users

type UserRetrieverMock added in v1.1.0

type UserRetrieverMock struct {
	CallerMock
	User      *user.User
	UserFound bool
	Err       error
}

UserRetrieverMock mocks the UserRetriever interface

func (*UserRetrieverMock) Get added in v1.1.0

func (userRetrieverMock *UserRetrieverMock) Get(userID id.ActorID) (*user.User, bool, error)

Get mocks getting a user

type UserUpdater

type UserUpdater interface {
	Update(pur *user.User) error
	Deactivate(user *user.User, isDelete bool) error
}

UserUpdater is used to update users

type UserUpdaterMock

type UserUpdaterMock struct {
	CallerMock
	Err error
}

func (*UserUpdaterMock) Deactivate

func (m *UserUpdaterMock) Deactivate(user *user.User, isDelete bool) error

func (*UserUpdaterMock) Update

func (m *UserUpdaterMock) Update(pur *user.User) error

type UserValidator added in v1.7.0

type UserValidator interface {
	Validate(identifier, password string) (*user.User, bool, error)
}

UserValidator is used to Validate an user

type UserValidatorMock added in v1.7.0

type UserValidatorMock struct {
	CallerMock
	User   user.User
	Exists bool
	Err    error
}

func (*UserValidatorMock) Validate added in v1.7.0

func (m *UserValidatorMock) Validate(identifier, password string) (*user.User, bool, error)

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.
This file is part of SystemTestPortal.
This file is part of SystemTestPortal.
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.
integration
ci_cd
Package ci_cd provides an integration into the CI/CD to analyze test results.
Package ci_cd provides an integration into the CI/CD to analyze test results.
gitlab
Package gitlab contains everything for the integration into gitlab.
Package gitlab contains everything for the integration into gitlab.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL