Documentation
¶
Overview ¶
Package database provides helper functions to connect to and interact with databases during automated tests.
Index ¶
- func DBConnection(t testing.TestingT, dbType string, dbConfig DBConfig) *sql.DBdeprecated
- func DBConnectionE(t testing.TestingT, dbType string, dbConfig DBConfig) (*sql.DB, error)deprecated
- func DBConnectionWithContextE(t testing.TestingT, ctx context.Context, dbType string, dbConfig *DBConfig) (*sql.DB, error)
- func DBExecution(t testing.TestingT, db *sql.DB, command string)deprecated
- func DBExecutionE(t testing.TestingT, db *sql.DB, command string) (sql.Result, error)deprecated
- func DBExecutionWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string) (sql.Result, error)
- func DBQuery(t testing.TestingT, db *sql.DB, command string) *sql.Rowsdeprecated
- func DBQueryE(t testing.TestingT, db *sql.DB, command string) (*sql.Rows, error)deprecated
- func DBQueryWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string) (*sql.Rows, error)
- func DBQueryWithCustomValidation(t testing.TestingT, db *sql.DB, command string, ...)deprecated
- func DBQueryWithCustomValidationE(t testing.TestingT, db *sql.DB, command string, ...) errordeprecated
- func DBQueryWithCustomValidationWithContextE(t testing.TestingT, ctx context.Context, db *sql.DB, command string, ...) error
- func DBQueryWithValidation(t testing.TestingT, db *sql.DB, command string, expected string)deprecated
- func DBQueryWithValidationE(t testing.TestingT, db *sql.DB, command string, expected string) errordeprecated
- type DBConfig
- type DBUnknown
- type ValidationFunctionFailed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DBConnection
deprecated
func DBConnectionE
deprecated
func DBConnectionWithContextE ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 DBQueryWithCustomValidation
deprecated
func DBQueryWithCustomValidation(t testing.TestingT, db *sql.DB, command string, validateResponse func(*sql.Rows) bool)
DBQueryWithCustomValidation queries from database and validates whether the result meets the requirement. If there's any error, fail the test.
Deprecated: Use DBQueryWithCustomValidationWithContextE instead.
func DBQueryWithCustomValidationE
deprecated
func DBQueryWithCustomValidationE(t testing.TestingT, db *sql.DB, command string, validateResponse func(*sql.Rows) bool) error
DBQueryWithCustomValidationE queries from database and validates whether the result meets the requirement. If not, returns an error.
Deprecated: Use DBQueryWithCustomValidationWithContextE instead.
func DBQueryWithCustomValidationWithContextE ¶ added in v1.0.0
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.
func DBQueryWithValidation
deprecated
DBQueryWithValidation queries from database and validates whether the result is the same as expected text. If there's any error, fail the test.
Deprecated: Use DBQueryWithCustomValidationWithContextE instead.
func DBQueryWithValidationE
deprecated
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