integration

package
v0.0.0-...-b779cef Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Overview

The package integration contains helpers to setup and teardown database for various connection types, as well as shared code to run the same tests for types and database/sql methods for the cgo and go implementation.

Files starting with `type_` contain functions to test a specific data type. These tests should follow these constraints:

  1. The underlying test should be run for each connection type once.
  2. Each separate test run must create its own table. The table must not be deleted after the test.
  3. If a type can be nulled the handling of the null value must be tested.

Files starting with `sql_` contain functions to test a function group from database/sql. These tests should follow these constraints:

  1. Methods accepting a context must be tested for their handling of the context.
  2. All execution paths must be tested. E.g. .Begin returns a transaction - which can be commmited or rolled back. In that case both the .Commit and the .Rollback must be tested.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ASE doesn't handle creating multiple databases concurrently well.
	// To prevent spurious test errors the DBCreateLock is used to
	// synchronise the goroutines creating databases.
	DBCreateLock = new(sync.Mutex)
)

Functions

func DoTestBigDateTime

func DoTestBigDateTime(t *testing.T)

DoTestBigDateTime tests the handling of the BigDateTime.

func DoTestBigInt

func DoTestBigInt(t *testing.T)

DoTestBigInt tests the handling of the BigInt.

func DoTestBigTime

func DoTestBigTime(t *testing.T)

DoTestBigTime tests the handling of the BigTime.

func DoTestBinary

func DoTestBinary(t *testing.T)

DoTestBinary tests the handling of the Binary.

func DoTestBit

func DoTestBit(t *testing.T)

DoTestBit tests the handling of the Bit.

func DoTestChar

func DoTestChar(t *testing.T)

DoTestChar tests the handling of the Char.

func DoTestDate

func DoTestDate(t *testing.T)

DoTestDate tests the handling of the Date.

func DoTestDateTime

func DoTestDateTime(t *testing.T)

DoTestDateTime tests the handling of the DateTime.

func DoTestDecimal

func DoTestDecimal(t *testing.T)

DoTestDecimal tests the handling of the Decimal.

func DoTestDecimal10

func DoTestDecimal10(t *testing.T)

DoTestDecimal10 tests the handling of the Decimal10.

func DoTestDecimal380

func DoTestDecimal380(t *testing.T)

DoTestDecimal380 tests the handling of the Decimal380.

func DoTestDecimal3838

func DoTestDecimal3838(t *testing.T)

DoTestDecimal3838 tests the handling of the Decimal3838.

func DoTestFloat

func DoTestFloat(t *testing.T)

DoTestFloat tests the handling of the Float.

func DoTestImage

func DoTestImage(t *testing.T)

DoTestImage tests the handling of the Image.

func DoTestInt

func DoTestInt(t *testing.T)

DoTestInt tests the handling of the Int.

func DoTestMoney

func DoTestMoney(t *testing.T)

DoTestMoney tests the handling of the Money.

func DoTestMoney4

func DoTestMoney4(t *testing.T)

DoTestMoney4 tests the handling of the Money4.

func DoTestNChar

func DoTestNChar(t *testing.T)

DoTestNChar tests the handling of the NChar.

func DoTestNVarChar

func DoTestNVarChar(t *testing.T)

DoTestNVarChar tests the handling of the NVarChar.

func DoTestNullBigDateTime

func DoTestNullBigDateTime(t *testing.T)

DoTestNullBigDateTime tests the handling of the NullBigDateTime.

func DoTestNullBigInt

func DoTestNullBigInt(t *testing.T)

DoTestNullBigInt tests the handling of the NullBigInt.

func DoTestNullBigTime

func DoTestNullBigTime(t *testing.T)

DoTestNullBigTime tests the handling of the NullBigTime.

func DoTestNullBinary

func DoTestNullBinary(t *testing.T)

DoTestNullBinary tests the handling of the NullBinary.

func DoTestNullChar

func DoTestNullChar(t *testing.T)

DoTestNullChar tests the handling of the NullChar.

func DoTestNullDate

func DoTestNullDate(t *testing.T)

DoTestNullDate tests the handling of the NullDate.

func DoTestNullDateTime

func DoTestNullDateTime(t *testing.T)

DoTestNullDateTime tests the handling of the NullDateTime.

func DoTestNullDecimal

func DoTestNullDecimal(t *testing.T)

DoTestNullDecimal tests the handling of the NullDecimal.

func DoTestNullFloat

func DoTestNullFloat(t *testing.T)

DoTestNullFloat tests the handling of the NullFloat.

func DoTestNullInt

func DoTestNullInt(t *testing.T)

DoTestNullInt tests the handling of the NullInt.

func DoTestNullMoney

func DoTestNullMoney(t *testing.T)

DoTestNullMoney tests the handling of the NullMoney.

func DoTestNullMoney4

func DoTestNullMoney4(t *testing.T)

DoTestNullMoney4 tests the handling of the NullMoney4.

func DoTestNullNChar

func DoTestNullNChar(t *testing.T)

DoTestNullNChar tests the handling of the NullNChar.

func DoTestNullNVarChar

func DoTestNullNVarChar(t *testing.T)

DoTestNullNVarChar tests the handling of the NullNVarChar.

func DoTestNullReal

func DoTestNullReal(t *testing.T)

DoTestNullReal tests the handling of the NullReal.

func DoTestNullSmallDateTime

func DoTestNullSmallDateTime(t *testing.T)

DoTestNullSmallDateTime tests the handling of the NullSmallDateTime.

func DoTestNullSmallInt

func DoTestNullSmallInt(t *testing.T)

DoTestNullSmallInt tests the handling of the NullSmallInt.

func DoTestNullTime

func DoTestNullTime(t *testing.T)

DoTestNullTime tests the handling of the NullTime.

func DoTestNullTinyInt

func DoTestNullTinyInt(t *testing.T)

DoTestNullTinyInt tests the handling of the NullTinyInt.

func DoTestNullUnsignedBigInt

func DoTestNullUnsignedBigInt(t *testing.T)

DoTestNullUnsignedBigInt tests the handling of the NullUnsignedBigInt.

func DoTestNullUnsignedInt

func DoTestNullUnsignedInt(t *testing.T)

DoTestNullUnsignedInt tests the handling of the NullUnsignedInt.

func DoTestNullUnsignedSmallInt

func DoTestNullUnsignedSmallInt(t *testing.T)

DoTestNullUnsignedSmallInt tests the handling of the NullUnsignedSmallInt.

func DoTestNullVarBinary

func DoTestNullVarBinary(t *testing.T)

DoTestNullVarBinary tests the handling of the NullVarBinary.

func DoTestNullVarChar

func DoTestNullVarChar(t *testing.T)

DoTestNullVarChar tests the handling of the NullVarChar.

func DoTestReal

func DoTestReal(t *testing.T)

DoTestReal tests the handling of the Real.

func DoTestSQLExec

func DoTestSQLExec(t *testing.T)

DoTestSQLExec runs tests for sql.Exec.

func DoTestSQLQueryRow

func DoTestSQLQueryRow(t *testing.T)

DoTestSQLQueryRow runs tests for sql.QueryRow.

func DoTestSQLTx

func DoTestSQLTx(t *testing.T)

DoTestSQLTx runs tests for sql.Tx.

func DoTestSmallDateTime

func DoTestSmallDateTime(t *testing.T)

DoTestSmallDateTime tests the handling of the SmallDateTime.

func DoTestSmallInt

func DoTestSmallInt(t *testing.T)

DoTestSmallInt tests the handling of the SmallInt.

func DoTestText

func DoTestText(t *testing.T)

DoTestText tests the handling of the Text.

func DoTestTime

func DoTestTime(t *testing.T)

DoTestTime tests the handling of the Time.

func DoTestTinyInt

func DoTestTinyInt(t *testing.T)

DoTestTinyInt tests the handling of the TinyInt.

func DoTestUniChar

func DoTestUniChar(t *testing.T)

DoTestUniChar tests the handling of the UniChar.

func DoTestUniText

func DoTestUniText(t *testing.T)

DoTestUniText tests the handling of the UniText.

func DoTestUnsignedBigInt

func DoTestUnsignedBigInt(t *testing.T)

DoTestUnsignedBigInt tests the handling of the UnsignedBigInt.

func DoTestUnsignedInt

func DoTestUnsignedInt(t *testing.T)

DoTestUnsignedInt tests the handling of the UnsignedInt.

func DoTestUnsignedSmallInt

func DoTestUnsignedSmallInt(t *testing.T)

DoTestUnsignedSmallInt tests the handling of the UnsignedSmallInt.

func DoTestVarBinary

func DoTestVarBinary(t *testing.T)

DoTestVarBinary tests the handling of the VarBinary.

func DoTestVarChar

func DoTestVarChar(t *testing.T)

DoTestVarChar tests the handling of the VarChar.

func RandomNumber

func RandomNumber() string

RandomNumber returns an unsecure random number as a string.

This method is used to ensure random names for similar objects being created for testing purposes in databases.

func RegisterDSN

func RegisterDSN(name string, info interface{}, connectorFn ConnectorCreator) error

RegisterDSN registers at least one new genSQLDBFn in genSQLDBMap based on sql.Open. If connectorFn is non-nil a second genSQLDBFn is stored with the suffix `connector`.

func SetupDB

func SetupDB(ctx context.Context, info interface{}, dbname string) error

SetupDB safely creates a database with the given name and sets .Database on the passed info.

func SetupTableInsert

func SetupTableInsert(db *sql.DB, tableName, aseType string, samples ...interface{}) (*sql.Rows, func() error, error)

SetupTableInsert creates a table with the passed type and inserts all passed samples as rows.

func TeardownDB

func TeardownDB(ctx context.Context, info interface{}) error

TeardownDB safely deletes the database indicated by .Database of the passed info and unsets the member.

func TestForEachDB

func TestForEachDB(testName string, t *testing.T, testFn DBTestFunc)

TestForEachDB runs the given DBTestFunc against all registered connection types.

Types

type ConnectorCreator

type ConnectorCreator func(interface{}) (driver.Connector, error)

ConnectorCreator is the interface for function expected by InitDBs to initialize driver.Connectors.

type DBTestFunc

type DBTestFunc func(t *testing.T, db *sql.DB, tableName string)

DBTestFunc is the interface for tests accepting a pre-connected sql.DB.

Jump to

Keyboard shortcuts

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