testhelpers

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 51 Imported by: 0

Documentation

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)

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(tableName 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) IAmUserWithID

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

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(tableName, columnName, columnValues string, data *messages.PickleStepArgument_PickleTable) error

func (*TestContext) TableAtColumnValueShouldBeEmpty

func (ctx *TestContext) TableAtColumnValueShouldBeEmpty(tableName string, columnName, columnValues string) error

func (*TestContext) TableShouldBe

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

func (*TestContext) TableShouldBeEmpty

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

func (*TestContext) TableShouldNotContainColumnValue

func (ctx *TestContext) TableShouldNotContainColumnValue(tableName, columnName, columnValues string) error

func (*TestContext) TableShouldStayUnchanged

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

func (*TestContext) TableShouldStayUnchangedButTheRowWithColumnValue

func (ctx *TestContext) TableShouldStayUnchangedButTheRowWithColumnValue(tableName, columnName, columnValues string) error

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) 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