Documentation ¶
Overview ¶
Package testutils provides utility methods for testing interactions with a MySQL backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BoolType = reflect.TypeOf(true) IntType = reflect.TypeOf(0) Int64Type = reflect.TypeOf(int64(0)) StringType = reflect.TypeOf(sql.NullString{}) TimeType = reflect.TypeOf(mysql.NullTime{}) )
Type constants for use with ValidateResult. TODO: There's probably a better way to handle this.
View Source
var DB *sql.DB
Functions ¶
func InitDB ¶
func InitDB(dbName string)
InitDB creates a database object shared across calls to the Validate functions.
func ValidateResourceVersion ¶
func ValidateResourceVersion(t *testing.T, resource resources.ResourceType, namespace, rv string)
ValidateResourceVersion checks that the stored resource version for the given namespace and resource is identical to that provided.
func ValidateResult ¶
func ValidateResult(t *testing.T, query string, expected_values []interface{}, expected_types []reflect.Type) bool
ValidateResult executes a SQL query and checks that its results match
those provided in expected_values. expected_types is an array with the reflect.Type values for expected_values; this allows nil values to be provided in expected_values. Queries should only return a single row; mismatches between the length of expected_values and the number of returned values by the query will likely cause runtime errors. Similarly, type failures will cause runtime errors. Mismatched values will result in calls to t.Log with a description of the expected and actual values. Returns true if all values are correct and if only a single row was returned and false otherwise.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.