testhelpers

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

Package testhelpers provides the interface and features to run the Gherkin tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyDB

func EmptyDB(db *sql.DB)

EmptyDB empties all tables of the database specified in the config

func FeatureContext

func FeatureContext(s *godog.Suite)

FeatureContext binds the supported steps to the verifying functions

func InsertBatch

func InsertBatch(db *sql.DB, tableName string, data []map[string]interface{})

InsertBatch insert the data into the table with the name given

func LoadFixture

func LoadFixture(db *sql.DB, fileName string)

LoadFixture loads fixtures from `<current_pkg_dir>/testdata/<fileName>/` directory or `<current_pkg_dir>/testdata/<fileName>` file. Each file in this directory must be in yaml format. If a file name satisfies '*.chain.yaml' mask, the file is treated as a tableName->[]dataRow map. Otherwise, data will be loaded into table with the same name as the filename (without extension). Note that you should probably empty the DB before using this function.

func MockDBTime

func MockDBTime(timeStrRaw string)

MockDBTime replaces the DB NOW() function call with a given constant value in all the queries

func OpenRawDBConnection

func OpenRawDBConnection() (*sql.DB, error)

OpenRawDBConnection creates a new connection to the DB specified in the config

func RestoreDBTime

func RestoreDBTime()

RestoreDBTime restores the usual behavior of the NOW() function

func RunConcurrently

func RunConcurrently(f func(), threadsNumber int)

RunConcurrently runs a given function concurrently

func RunGodogTests

func RunGodogTests(t *testing.T, tags string)

RunGodogTests launches GoDog tests (bdd tests) for the current directory (the one from the tested package)

func SetupDBWithFixture

func SetupDBWithFixture(fixtureNames ...string) *database.DB

SetupDBWithFixture creates a new DB connection, empties the DB, and loads a fixture

func SetupDBWithFixtureString

func SetupDBWithFixtureString(fixtures ...string) *database.DB

SetupDBWithFixtureString creates a new DB connection, empties the DB, and loads fixtures from the strings (yaml with a tableName->[]dataRow map)

func ValidateJSONContentType

func ValidateJSONContentType(resp *http.Response) error

ValidateJSONContentType validates the content-type header of the response is json If not, return an error

Types

type TestContext

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

TestContext implements context for tests

func (*TestContext) DBGroupsAncestorsAreComputed

func (ctx *TestContext) DBGroupsAncestorsAreComputed() error

func (*TestContext) DBHasTable

func (ctx *TestContext) DBHasTable(table string, data *messages.PickleStepArgument_PickleTable) error

func (*TestContext) DBHasUsers

func (ctx *TestContext) DBHasUsers(data *messages.PickleStepArgument_PickleTable) error

func (*TestContext) DbTimeNow

func (ctx *TestContext) DbTimeNow(timeStrRaw string) error

func (*TestContext) IAm added in v1.8.0

func (ctx *TestContext) IAm(name string) error

IAm Sets the current user.

func (*TestContext) IAmAMemberOfTheGroupWithID added in v1.8.0

func (ctx *TestContext) IAmAMemberOfTheGroupWithID(groupID int64) error

IAmAMemberOfTheGroupWithID creates a group and add the user in it.

func (*TestContext) IAmPartOfTheHelperGroupOfTheThread added in v1.8.0

func (ctx *TestContext) IAmPartOfTheHelperGroupOfTheThread() error

IAmPartOfTheHelperGroupOfTheThread states that user is a member of the helper group of a given thread.

func (*TestContext) IAmTheManagerOfTheGroup added in v1.8.0

func (ctx *TestContext) IAmTheManagerOfTheGroup(groupID int64) error

IAmTheManagerOfTheGroup sets the user as a manager of a group.

func (*TestContext) IAmTheManagerOfTheGroupWith added in v1.8.0

func (ctx *TestContext) IAmTheManagerOfTheGroupWith(groupID int64, canWatchMembers bool) error

IAmTheManagerOfTheGroupWith sets the current user as the manager of a group.

func (*TestContext) IAmUserWithID

func (ctx *TestContext) IAmUserWithID(userID int64) error

func (*TestContext) ICanOnItemWithID added in v1.8.0

func (ctx *TestContext) ICanOnItemWithID(watchType, watchValue string, itemID int64) error

ICanOnItemWithID gives the user a permission on an item.

func (*TestContext) ICanRequestHelpToTheGroupWithIDOnTheItemWithID added in v1.8.0

func (ctx *TestContext) ICanRequestHelpToTheGroupWithIDOnTheItemWithID(groupID, itemID int64) error

ICanRequestHelpToTheGroupWithIDOnTheItemWithID gives the user the permission to request help from a given group to a given item.

func (*TestContext) ICanViewOnItemWithID added in v1.8.0

func (ctx *TestContext) ICanViewOnItemWithID(watchValue string, itemID int64) error

ICanViewOnItemWithID gives the user a "view" permission on an item.

func (*TestContext) ICanWatchOnItemWithID added in v1.8.0

func (ctx *TestContext) ICanWatchOnItemWithID(watchValue string, itemID int64) error

ICanWatchOnItemWithID gives the user a "watch" permission on an item.

func (*TestContext) ICanWatchParticipantWithID added in v1.8.0

func (ctx *TestContext) ICanWatchParticipantWithID(participantID int64) error

ICanWatchParticipantWithID adds the permission for the user to watch a participant.

func (*TestContext) IHaveValidatedItemWithID added in v1.8.0

func (ctx *TestContext) IHaveValidatedItemWithID(itemID int64) error

IHaveValidatedItemWithID states that user has validated an item.

func (*TestContext) ISendrequestTo

func (ctx *TestContext) ISendrequestTo(method string, path string) error

func (*TestContext) ISendrequestToWithBody

func (ctx *TestContext) ISendrequestToWithBody(method string, path string, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) ItShouldBeAJSONArrayWithEntries

func (ctx *TestContext) ItShouldBeAJSONArrayWithEntries(count int) error

func (*TestContext) LogsShouldContain

func (ctx *TestContext) LogsShouldContain(docString *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) ScenarioTeardown

func (ctx *TestContext) ScenarioTeardown(*messages.Pickle, error)

func (*TestContext) SetupTestContext

func (ctx *TestContext) SetupTestContext(pickle *messages.Pickle)

func (*TestContext) SignedTokenIsDistributed

func (ctx *TestContext) SignedTokenIsDistributed(varName, signerName string, docString *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TableAtColumnValueShouldBe

func (ctx *TestContext) TableAtColumnValueShouldBe(table, column, values string, data *messages.PickleStepArgument_PickleTable) error

func (*TestContext) TableAtColumnValueShouldBeEmpty

func (ctx *TestContext) TableAtColumnValueShouldBeEmpty(table string, column, valuesStr string) error

func (*TestContext) TableShouldBe

func (ctx *TestContext) TableShouldBe(table string, data *messages.PickleStepArgument_PickleTable) error

func (*TestContext) TableShouldBeEmpty

func (ctx *TestContext) TableShouldBeEmpty(table string) error

func (*TestContext) TableShouldNotContainColumnValue

func (ctx *TestContext) TableShouldNotContainColumnValue(table, column, values string) error

func (*TestContext) TableShouldStayUnchanged

func (ctx *TestContext) TableShouldStayUnchanged(table string) error

func (*TestContext) TableShouldStayUnchangedButTheRowWithColumnValue

func (ctx *TestContext) TableShouldStayUnchangedButTheRowWithColumnValue(table, column, values string) error

func (*TestContext) TableShouldStayUnchangedButTheRowsWithColumnValueShouldBeDeleted added in v1.8.0

func (ctx *TestContext) TableShouldStayUnchangedButTheRowsWithColumnValueShouldBeDeleted(table, columns, values string) error

TableShouldStayUnchangedButTheRowsWithColumnValueShouldBeDeleted checks for row deletion

func (*TestContext) TheApplicationConfigIs

func (ctx *TestContext) TheApplicationConfigIs(body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheContextVariableIs

func (ctx *TestContext) TheContextVariableIs(variableName, value string) error

func (*TestContext) TheGeneratedAuthKeyIs

func (ctx *TestContext) TheGeneratedAuthKeyIs(generatedString string) error

func (*TestContext) TheGeneratedAuthKeysAre

func (ctx *TestContext) TheGeneratedAuthKeysAre(generatedStrings string) error

func (*TestContext) TheGeneratedGroupCodeIs

func (ctx *TestContext) TheGeneratedGroupCodeIs(generatedCode string) error

func (*TestContext) TheGeneratedGroupCodesAre

func (ctx *TestContext) TheGeneratedGroupCodesAre(generatedCodes string) error

func (*TestContext) TheLoginModuleAccountEndpointForTokenReturns

func (ctx *TestContext) TheLoginModuleAccountEndpointForTokenReturns(token string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleCreateEndpointWithParamsReturns

func (ctx *TestContext) TheLoginModuleCreateEndpointWithParamsReturns(
	params string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleDeleteEndpointWithParamsReturns

func (ctx *TestContext) TheLoginModuleDeleteEndpointWithParamsReturns(
	params string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleLTIResultSendEndpointForUserIDContentIDScoreReturns

func (ctx *TestContext) TheLoginModuleLTIResultSendEndpointForUserIDContentIDScoreReturns(
	userID, contentID, score string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleTokenEndpointForCodeAndCodeVerifierAndRedirectURIReturns

func (ctx *TestContext) TheLoginModuleTokenEndpointForCodeAndCodeVerifierAndRedirectURIReturns(code, codeVerifier, redirectURI string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleTokenEndpointForCodeAndCodeVerifierReturns

func (ctx *TestContext) TheLoginModuleTokenEndpointForCodeAndCodeVerifierReturns(code, codeVerifier string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleTokenEndpointForCodeReturns

func (ctx *TestContext) TheLoginModuleTokenEndpointForCodeReturns(code string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleTokenEndpointForRefreshTokenReturns

func (ctx *TestContext) TheLoginModuleTokenEndpointForRefreshTokenReturns(refreshToken string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheLoginModuleUnlinkClientEndpointForUserIDReturns

func (ctx *TestContext) TheLoginModuleUnlinkClientEndpointForUserIDReturns(
	userID string, statusCode int, body *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheRequestHeaderIs

func (ctx *TestContext) TheRequestHeaderIs(name, value string) error

func (*TestContext) TheResponseBodyShouldBe

func (ctx *TestContext) TheResponseBodyShouldBe(body *messages.PickleStepArgument_PickleDocString) (err error)

func (*TestContext) TheResponseBodyShouldBeJSON

func (ctx *TestContext) TheResponseBodyShouldBeJSON(body *messages.PickleStepArgument_PickleDocString) (err error)

func (*TestContext) TheResponseCodeShouldBe

func (ctx *TestContext) TheResponseCodeShouldBe(code int) error

func (*TestContext) TheResponseDecodedBodyShouldBeJSON

func (ctx *TestContext) TheResponseDecodedBodyShouldBeJSON(responseType string, body *messages.PickleStepArgument_PickleDocString) (err error)

func (*TestContext) TheResponseErrorMessageShouldContain

func (ctx *TestContext) TheResponseErrorMessageShouldContain(s string) (err error)

func (*TestContext) TheResponseHeaderShouldBe

func (ctx *TestContext) TheResponseHeaderShouldBe(headerName string, headerValue string) (err error)

func (*TestContext) TheResponseHeadersShouldBe

func (ctx *TestContext) TheResponseHeadersShouldBe(headerName string, headersValue *messages.PickleStepArgument_PickleDocString) (err error)

func (*TestContext) TheResponseShouldBe

func (ctx *TestContext) TheResponseShouldBe(kind string) error

func (*TestContext) TheTemplateConstantIsDocString

func (ctx *TestContext) TheTemplateConstantIsDocString(name string, value *messages.PickleStepArgument_PickleDocString) error

func (*TestContext) TheTemplateConstantIsString

func (ctx *TestContext) TheTemplateConstantIsString(name, value string) error

func (*TestContext) ThereIsAGroupWith added in v1.8.0

func (ctx *TestContext) ThereIsAGroupWith(parameters string) error

ThereIsAGroupWith creates a new group.

func (*TestContext) ThereIsAThreadWith added in v1.8.0

func (ctx *TestContext) ThereIsAThreadWith(parameters string) error

ThereIsAThreadWith creates a thread.

func (*TestContext) ThereIsAUserWith added in v1.8.0

func (ctx *TestContext) ThereIsAUserWith(parameters string) error

ThereIsAUserWith creates a new user.

func (*TestContext) ThereIsNoThreadWith added in v1.8.0

func (ctx *TestContext) ThereIsNoThreadWith(parameters string) error

ThereIsNoThreadWith states that a given thread doesn't exist.

func (*TestContext) TimeIsFrozen

func (ctx *TestContext) TimeIsFrozen() error

func (*TestContext) TimeNow

func (ctx *TestContext) TimeNow(timeStr string) error

Jump to

Keyboard shortcuts

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