database

package module
v2.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 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 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 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