Documentation
¶
Index ¶
- Variables
- func AssertClauseSerialize(t *testing.T, dialect jet.Dialect, clause jet.Clause, query string, ...)
- func AssertDebugSerialize(t *testing.T, dialect jet.Dialect, clause jet.Serializer, query string, ...)
- func AssertDebugStatementSql(t *testing.T, query jet.PrintableStatement, expectedQuery string, ...)
- func AssertDeepEqual(t require.TestingT, actual, expected interface{}, option ...cmp.Option)
- func AssertExec(t *testing.T, stmt jet.Statement, db qrm.DB, rowsAffected ...int64)
- func AssertExecAndRollback(t *testing.T, stmt jet.Statement, db *stmtcache.DB, rowsAffected ...int64)
- func AssertExecContext(t *testing.T, stmt jet.Statement, ctx context.Context, db qrm.DB, ...)
- func AssertExecContextErr(ctx context.Context, t *testing.T, stmt jet.Statement, db qrm.DB, ...)
- func AssertExecErr(t *testing.T, stmt jet.Statement, db qrm.DB, errorStr string)
- func AssertFileContent(t *testing.T, filePath string, expectedContent string)
- func AssertFileNamesEqual(t *testing.T, dirPath string, fileNames ...string)
- func AssertJSON(t *testing.T, data interface{}, expectedJSON string)
- func AssertJSONFile(t require.TestingT, data interface{}, testRelativePath string)
- func AssertJsonEqual(t require.TestingT, actual, expected interface{}, option ...cmp.Option)
- func AssertOptLiteral(t *testing.T, dialect jet.Dialect, plain, some, none jet.Serializer, ...)
- func AssertOptionFields(t require.TestingT, row any, want bool) int
- func AssertOptionParity(t require.TestingT, optRow, ptrRow any)
- func AssertPanicErr(t *testing.T, fun func(), errorStr string)
- func AssertPointerFieldsNil(t require.TestingT, row any)
- func AssertProjectionSerialize(t *testing.T, dialect jet.Dialect, projection jet.Projection, query string, ...)
- func AssertQueryPanicErr(t *testing.T, stmt jet.Statement, db qrm.DB, dest interface{}, ...)
- func AssertSerialize(t *testing.T, dialect jet.Dialect, serializer jet.Serializer, query string, ...)
- func AssertSerializeErr(t *testing.T, dialect jet.Dialect, clause jet.Serializer, errString string)
- func AssertStatementSql(t require.TestingT, query jet.PrintableStatement, expectedQuery string, ...)
- func AssertStatementSqlErr(t *testing.T, stmt jet.Statement, errorStr string)
- func Date(t string) *time.Time
- func DeepCopy[T any](t require.TestingT, src T) T
- func ExecuteInTxAndRollback(t *testing.T, db *stmtcache.DB, f func(tx qrm.DB))
- func PrintJson(v interface{})
- func ReadJSONFile(t require.TestingT, testRelativePath string, dest any)
- func SaveJSONFile(v interface{}, testRelativePath string)
- func TimeWithTimeZone(t string) *time.Time
- func TimeWithoutTimeZone(t string) *time.Time
- func TimestampWithTimeZone(t string, precision int) *time.Time
- func TimestampWithoutTimeZone(t string, precision int) *time.Time
- func ToJSON(v interface{}) string
- func UUIDPtr(u string) *uuid.UUID
Constants ¶
This section is empty.
Variables ¶
var OptionComparable = cmp.Exporter(func(t reflect.Type) bool { _, ok := optional.Elem(t) return ok })
OptionComparable lets go-cmp (AssertDeepEqual) compare functional.Option values, whose fields are unexported. Equal methods of the carried values (time.Time, decimal.Decimal) still apply.
var UnixTimeComparer = cmp.Comparer(func(t1, t2 time.Time) bool {
return t1.Unix() == t2.Unix()
})
UnixTimeComparer will compare time equality while ignoring time zone
Functions ¶
func AssertClauseSerialize ¶
func AssertClauseSerialize(t *testing.T, dialect jet.Dialect, clause jet.Clause, query string, args ...interface{})
AssertClauseSerialize checks if clause serialize produces expected query and args
func AssertDebugSerialize ¶
func AssertDebugSerialize(t *testing.T, dialect jet.Dialect, clause jet.Serializer, query string, args ...interface{})
AssertDebugSerialize checks if clause serialize produces expected debug query and args
func AssertDebugStatementSql ¶
func AssertDebugStatementSql(t *testing.T, query jet.PrintableStatement, expectedQuery string, expectedArgs ...interface{})
AssertDebugStatementSql check if statement Sql() is the same as expectedQuery
func AssertDeepEqual ¶
AssertDeepEqual checks if actual and expected objects are deeply equal.
func AssertExec ¶
AssertExec assert statement execution for successful execution and number of rows affected
func AssertExecAndRollback ¶
func AssertExecAndRollback(t *testing.T, stmt jet.Statement, db *stmtcache.DB, rowsAffected ...int64)
AssertExecAndRollback will execute and rollback statement in sql transaction
func AssertExecContext ¶
func AssertExecContext(t *testing.T, stmt jet.Statement, ctx context.Context, db qrm.DB, rowsAffected ...int64)
AssertExecContext assert statement execution for successful execution and number of rows affected
func AssertExecContextErr ¶
func AssertExecContextErr(ctx context.Context, t *testing.T, stmt jet.Statement, db qrm.DB, errorStr string)
AssertExecContextErr assert statement execution for failed execution with error string errorStr
func AssertExecErr ¶
AssertExecErr assert statement execution for failed execution with error string errorStr
func AssertFileContent ¶
AssertFileContent check if file content at filePath contains expectedContent text.
func AssertFileNamesEqual ¶
AssertFileNamesEqual check if all filesInfos are contained in fileNames
func AssertJSON ¶
AssertJSON check if data json output is the same as expectedJSON
func AssertJSONFile ¶
AssertJSONFile check if data json representation is the same as json at testRelativePath
func AssertJsonEqual ¶
AssertJsonEqual checks if actual and expected json representation are the same
func AssertOptLiteral ¶
func AssertOptLiteral(t *testing.T, dialect jet.Dialect, plain, some, none jet.Serializer, debugNone string)
AssertOptLiteral checks an XxxOpt literal constructor against its plain constructor: some (XxxOpt(Some(v))) must serialize exactly like plain (Xxx(v)); none (XxxOpt(None)) must give the same SQL with a nil argument, and debugNone in debug SQL.
func AssertOptionFields ¶
AssertOptionFields checks that every functional.Option field of row is present (want true) or absent (want false), and returns how many Option fields it checked.
func AssertOptionParity ¶
AssertOptionParity checks that optRow, a struct with functional.Option fields, holds the same data as ptrRow, the same struct generated with pointers. It walks optRow's fields by name. An Option field is compared through ToPtr with the pointer field; other fields directly. Named types with the same underlying type (an enum generated into two packages) are converted before the comparison.
func AssertPanicErr ¶
AssertPanicErr checks if running a function fun produces a panic with errorStr string
func AssertPointerFieldsNil ¶
AssertPointerFieldsNil checks that every pointer field of row is nil.
func AssertProjectionSerialize ¶
func AssertProjectionSerialize(t *testing.T, dialect jet.Dialect, projection jet.Projection, query string, args ...interface{})
AssertProjectionSerialize check if projection serialize produces expected query and args
func AssertQueryPanicErr ¶
func AssertQueryPanicErr(t *testing.T, stmt jet.Statement, db qrm.DB, dest interface{}, errString string)
AssertQueryPanicErr check if statement Query execution panics with error errString
func AssertSerialize ¶
func AssertSerialize(t *testing.T, dialect jet.Dialect, serializer jet.Serializer, query string, args ...interface{})
AssertSerialize checks if clause serialize produces expected query and args
func AssertSerializeErr ¶
AssertSerializeErr check if clause serialize panics with errString
func AssertStatementSql ¶
func AssertStatementSql(t require.TestingT, query jet.PrintableStatement, expectedQuery string, expectedArgs ...interface{})
AssertStatementSql check if statement Sql() is the same as expectedQuery and expectedArgs
func AssertStatementSqlErr ¶
AssertStatementSqlErr checks if statement Sql() panics with errorStr
func ExecuteInTxAndRollback ¶
ExecuteInTxAndRollback will execute function in sql transaction and then rollback transaction
func SaveJSONFile ¶
func SaveJSONFile(v interface{}, testRelativePath string)
SaveJSONFile saves v as json at testRelativePath nolint:unused
func TimeWithTimeZone ¶
TimeWithTimeZone creates time from t
func TimeWithoutTimeZone ¶
TimeWithoutTimeZone creates time from t
func TimestampWithTimeZone ¶
TimestampWithTimeZone creates time from t
func TimestampWithoutTimeZone ¶
TimestampWithoutTimeZone creates time from t
Types ¶
This section is empty.