database

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBConnection

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

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

func DBConnectionE

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

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

func DBExecution

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

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

func DBExecutionE

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

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

func DBQuery

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

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

func DBQueryE

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

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

func DBQueryWithCustomValidation

func DBQueryWithCustomValidation(t *testing.T, db *sql.DB, command string, validateResponse func(*sql.Rows) bool)

DBQueryWithCustomValidation queries from database and validate whether the result meets the requirement. If there's any error, fail the test.

func DBQueryWithCustomValidationE

func DBQueryWithCustomValidationE(t *testing.T, db *sql.DB, command string, validateResponse func(*sql.Rows) bool) error

DBQueryWithCustomValidationE queries from database and validate whether the result meets the requirement. If not, return an error.

func DBQueryWithValidation

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

DBQueryWithValidation queries from database and validate whether the result is the same as expected text. If there's any error, fail the test.

func DBQueryWithValidationE

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

DBQueryWithValidationE queries from database and validate whether the result is the same as expected text. If not, return 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