Documentation ¶
Index ¶
- func AssertQueryRuns(connection *dbconn.DBConn, query string)
- func CreateAndConnectMockDB(numConns int) (*dbconn.DBConn, sqlmock.Sqlmock)
- func CreateMockDB() (*sqlx.DB, sqlmock.Sqlmock)
- func CreateMockDBConn(errs ...error) (*dbconn.DBConn, sqlmock.Sqlmock)
- func ExpectRegexp(buffer *gbytes.Buffer, testStr string)
- func ExpectVersionQuery(mock sqlmock.Sqlmock, versionStr string)
- func MockFileContents(contents string)
- func NotExpectRegexp(buffer *gbytes.Buffer, testStr string)
- func SetDBVersion(connection *dbconn.DBConn, versionStr string)
- func SetupTestEnvironment() (*dbconn.DBConn, sqlmock.Sqlmock, *gbytes.Buffer, *gbytes.Buffer, ...)
- func SetupTestLogger() (*gbytes.Buffer, *gbytes.Buffer, *gbytes.Buffer)
- func ShouldPanicWithMessage(message string)
- type TestDriver
- type TestExecutor
- type TestResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertQueryRuns ¶
func CreateAndConnectMockDB ¶
func ExpectRegexp ¶
func ExpectVersionQuery ¶
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 SetDBVersion ¶
* 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 ShouldPanicWithMessage ¶
func ShouldPanicWithMessage(message string)
Types ¶
type TestDriver ¶
type TestExecutor ¶
type TestExecutor struct { LocalOutput string LocalOutputs []string LocalError error LocalErrors []error LocalCommands []string ClusterOutput *cluster.RemoteOutput ClusterOutputs []*cluster.RemoteOutput ClusterCommands [][]cluster.ShellCommand ErrorOnExecNum int // Return LocalError after this many calls of ExecuteLocalCommand (0 means always return error); has no effect for ExecuteClusterCommand NumExecutions int // Total of NumLocalExecutions and NumClusterExecutions, for convenience and backwards compatibility NumLocalExecutions int NumClusterExecutions int UseLastOutput bool // If we run out of LocalOutputs/LocalErrors or ClusterOutputs, default to the final items in those arrays UseDefaultOutput bool // If we run out of LocalOutputs/LocalErrors or ClusterOutputs, default to LocalOutput/LocalError or ClusterOutput }
* Each output or error type has both a plural form and a singular form. If the plural form is set, it overrides the singular. * The singular form returns the same output and error on each call; the plural form returns one output per call (first element on the first call, etc.) * If more calls are made than there are outputs provided a Fatal error is raised, unless UseDefaultOutput or UseLastOutput is set. * * The LocalOutputs and LocalErrors arrays are "paired" in that the struct doesn't know how "normal" calls and "error" calls will be interleaved, so if * N calls are expected then at least N outputs and N errors must be provided; even if UseLastOutput or UseDefaultOutput is set in order to define its * behavior when more than N calls are made and it runs out of outputs and errors to return, the two array lengths must still be identical.
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)