database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package database provides helper functions to connect to and interact with databases during automated tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBConnection deprecated

func DBConnection(t testing.TestingT, dbType string, dbConfig DBConfig) *sql.DB

DBConnection connects to the database using database configuration and database type, i.e. mssql, and then returns the database. If there's any error, fail the test.

Deprecated: Use DBConnectionWithContextE instead.

func DBConnectionE deprecated

func DBConnectionE(t testing.TestingT, dbType string, dbConfig DBConfig) (*sql.DB, error)

DBConnectionE connects to the database using database configuration and database type, i.e. mssql. Returns the database or an error.

Deprecated: Use DBConnectionWithContextE instead.

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 DBExecution deprecated

func DBExecution(t testing.TestingT, db *sql.DB, command string)

DBExecution executes specific SQL commands, i.e. insertion. If there's any error, fail the test.

Deprecated: Use DBExecutionWithContextE instead.

func DBExecutionE deprecated

func DBExecutionE(t testing.TestingT, db *sql.DB, command string) (sql.Result, error)

DBExecutionE executes specific SQL commands, i.e. insertion. Returns the result or an error.

Deprecated: Use DBExecutionWithContextE instead.

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 DBQuery deprecated

func DBQuery(t testing.TestingT, db *sql.DB, command string) *sql.Rows

DBQuery queries from database, i.e. selection, and then returns the result. If there's any error, fail the test.

Deprecated: Use DBQueryWithContextE instead.

func DBQueryE deprecated

func DBQueryE(t testing.TestingT, db *sql.DB, command string) (*sql.Rows, error)

DBQueryE queries from database, i.e. selection. Returns the result or an error.

Deprecated: Use DBQueryWithContextE instead.

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

func DBQueryWithValidation(t testing.TestingT, db *sql.DB, command string, expected string)

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

func DBQueryWithValidationE(t testing.TestingT, db *sql.DB, command string, expected string) error

DBQueryWithValidationE queries from database and validates whether the result is the same as expected text. If not, returns an error.

Deprecated: Use DBQueryWithCustomValidationWithContextE instead.

Types

type DBConfig

type DBConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}

DBConfig using server name, user name, password and database name.

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.

func (DBUnknown) Error

func (err DBUnknown) Error() string

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

Jump to

Keyboard shortcuts

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