testhelper

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertQueryRuns

func AssertQueryRuns(connection *dbconn.DBConn, query string)

func CreateAndConnectMockDB

func CreateAndConnectMockDB(numConns int) (*dbconn.DBConn, sqlmock.Sqlmock)

func CreateMockDB

func CreateMockDB() (*sqlx.DB, sqlmock.Sqlmock)

func CreateMockDBConn

func CreateMockDBConn(errs ...error) (*dbconn.DBConn, sqlmock.Sqlmock)

func ExpectRegexp

func ExpectRegexp(buffer *gbytes.Buffer, testStr string)

func ExpectVersionQuery

func ExpectVersionQuery(mock sqlmock.Sqlmock, versionStr string)

func MockFileContents

func MockFileContents(contents string)

* This function call should be followed by a call to InitializeSystemFunctions * in a defer statement or AfterEach block.

func NotExpectRegexp

func NotExpectRegexp(buffer *gbytes.Buffer, testStr string)

func SetDBVersion

func SetDBVersion(connection *dbconn.DBConn, versionStr string)

* While this function is technically redundant with dbconn.NewVersion, it's * here to allow `defer`ing version changes easily, instead of needing e.g. * "defer func() { connection.Version = dbconn.NewVersion(versionStr) }()" or * something similarly ugly.

func SetupTestEnvironment

func SetupTestEnvironment() (*dbconn.DBConn, sqlmock.Sqlmock, *gbytes.Buffer, *gbytes.Buffer, *gbytes.Buffer)

func SetupTestLogger

func SetupTestLogger() (*gbytes.Buffer, *gbytes.Buffer, *gbytes.Buffer)

func ShouldPanicWithMessage

func ShouldPanicWithMessage(message string)

Types

type TestDriver

type TestDriver struct {
	ErrToReturn  error
	ErrsToReturn []error
	DB           *sqlx.DB
	DBName       string
	User         string
	CallNumber   int
}

func (*TestDriver) Connect

func (driver *TestDriver) Connect(driverName string, dataSourceName string) (*sqlx.DB, error)

type TestExecutor

type TestExecutor struct {
	LocalOutput     string
	LocalError      error
	LocalCommands   []string
	ClusterOutput   *cluster.RemoteOutput
	ClusterCommands [][]cluster.ShellCommand
	ErrorOnExecNum  int // Throw the specified error after this many executions of Execute[...]Command(); 0 means always return error
	NumExecutions   int
}

func (*TestExecutor) ExecuteClusterCommand

func (executor *TestExecutor) ExecuteClusterCommand(scope cluster.Scope, commandList []cluster.ShellCommand) *cluster.RemoteOutput

func (*TestExecutor) ExecuteLocalCommand

func (executor *TestExecutor) ExecuteLocalCommand(commandStr string) (string, error)

type TestResult

type TestResult struct {
	Rows int64
}

func (TestResult) LastInsertId

func (result TestResult) LastInsertId() (int64, error)

func (TestResult) RowsAffected

func (result TestResult) RowsAffected() (int64, error)

Jump to

Keyboard shortcuts

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