Documentation
¶
Overview ¶
Package database provides helper functions to connect to and interact with databases during automated tests.
Index ¶
- func DBConnectionWithContextE(t testing.TestingT, ctx context.Context, dbType string, dbConfig *DBConfig) (*sql.DB, error)
- func DBExecutionWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string) (sql.Result, error)
- func DBQueryWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string) (*sql.Rows, error)
- func DBQueryWithCustomValidationWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string, ...) error
- type DBConfig
- type DBUnknown
- type ValidationFunctionFailed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DBConnectionWithContextE ¶
func DBConnectionWithContextE(t testing.TestingT, ctx context.Context, dbType string, dbConfig *DBConfig) (*sql.DB, error)
DBConnectionWithContextE connects to the database using database configuration and database type, i.e. mssql. Returns the database or an error.
func DBExecutionWithContextE ¶
func DBExecutionWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string) (sql.Result, error)
DBExecutionWithContextE executes specific SQL commands, i.e. insertion. Returns the result or an error.
func DBQueryWithContextE ¶
func DBQueryWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string) (*sql.Rows, error)
DBQueryWithContextE queries from database, i.e. selection. Returns the result or an error.
func DBQueryWithCustomValidationWithContextE ¶
func DBQueryWithCustomValidationWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string, validateResponse func(*sql.Rows) bool) error
DBQueryWithCustomValidationWithContextE queries from database and validates whether the result meets the requirement. If not, returns an error.
Types ¶
type DBUnknown ¶
type DBUnknown struct {
// contains filtered or unexported fields
}
DBUnknown is an error that occurs if the given database type is unknown or not supported.
type ValidationFunctionFailed ¶
type ValidationFunctionFailed struct {
// contains filtered or unexported fields
}
ValidationFunctionFailed is an error that occurs if the validation function fails.
func (ValidationFunctionFailed) Error ¶
func (err ValidationFunctionFailed) Error() string