testutils

package
v0.0.0-...-894d565 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0, BSD-3-Clause, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.Statement, expectedQuery string, expectedArgs ...interface{})

AssertDebugStatementSql check if statement Sql() is the same as expectedQuery

func AssertDeepEqual

func AssertDeepEqual(t *testing.T, actual, expected interface{}, option ...cmp.Option)

AssertDeepEqual checks if actual and expected objects are deeply equal.

func AssertExec

func AssertExec(t *testing.T, stmt jet.Statement, db qrm.DB, rowsAffected ...int64)

AssertExec assert statement execution for successful execution and number of rows affected

func AssertExecAndRollback

func AssertExecAndRollback(t *testing.T, stmt jet.Statement, db *sql.DB, rowsAffected ...int64)

AssertExecAndRollback will execute and rollback statement in sql transaction

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

func AssertExecErr(t *testing.T, stmt jet.Statement, db qrm.DB, errorStr string)

AssertExecErr assert statement execution for failed execution with error string errorStr

func AssertFileContent

func AssertFileContent(t *testing.T, filePath string, expectedContent string)

AssertFileContent check if file content at filePath contains expectedContent text.

func AssertFileNamesEqual

func AssertFileNamesEqual(t *testing.T, dirPath string, fileNames ...string)

AssertFileNamesEqual check if all filesInfos are contained in fileNames

func AssertJSON

func AssertJSON(t *testing.T, data interface{}, expectedJSON string)

AssertJSON check if data json output is the same as expectedJSON

func AssertJSONFile

func AssertJSONFile(t *testing.T, data interface{}, testRelativePath string)

AssertJSONFile check if data json representation is the same as json at testRelativePath

func AssertPanicErr

func AssertPanicErr(t *testing.T, fun func(), errorStr string)

AssertPanicErr checks if running a function fun produces a panic with errorStr string

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

func AssertSerializeErr(t *testing.T, dialect jet.Dialect, clause jet.Serializer, errString string)

AssertSerializeErr check if clause serialize panics with errString

func AssertStatementSql

func AssertStatementSql(t *testing.T, query jet.Statement, expectedQuery string, expectedArgs ...interface{})

AssertStatementSql check if statement Sql() is the same as expectedQuery and expectedArgs

func AssertStatementSqlErr

func AssertStatementSqlErr(t *testing.T, stmt jet.Statement, errorStr string)

AssertStatementSqlErr checks if statement Sql() panics with errorStr

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns address of bool parameter

func ByteArrayPtr

func ByteArrayPtr(arr []byte) *[]byte

ByteArrayPtr returns address of []byte parameter

func Date

func Date(t string) *time.Time

Date creates time from t string

func ExecuteInTxAndRollback

func ExecuteInTxAndRollback(t *testing.T, db *sql.DB, f func(tx *sql.Tx))

ExecuteInTxAndRollback will execute function in sql transaction and then rollback transaction

func Float32Ptr

func Float32Ptr(f float32) *float32

Float32Ptr returns address of float32 parameter

func Float64Ptr

func Float64Ptr(f float64) *float64

Float64Ptr returns address of float64 parameter

func Int16Ptr

func Int16Ptr(i int16) *int16

Int16Ptr returns address of int16 parameter

func Int32Ptr

func Int32Ptr(i int32) *int32

Int32Ptr returns address of int32 parameter

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr returns address of int64 parameter

func Int8Ptr

func Int8Ptr(i int8) *int8

Int8Ptr returns address of int8 parameter

func PrintJson

func PrintJson(v interface{})

PrintJson print v as json

func SaveJSONFile

func SaveJSONFile(v interface{}, testRelativePath string)

SaveJSONFile saves v as json at testRelativePath

func StringPtr

func StringPtr(s string) *string

StringPtr returns address of string parameter

func TimePtr

func TimePtr(t time.Time) *time.Time

TimePtr returns address of time.Time parameter

func TimeWithTimeZone

func TimeWithTimeZone(t string) *time.Time

TimeWithTimeZone creates time from t

func TimeWithoutTimeZone

func TimeWithoutTimeZone(t string) *time.Time

TimeWithoutTimeZone creates time from t

func TimestampWithTimeZone

func TimestampWithTimeZone(t string, precision int) *time.Time

TimestampWithTimeZone creates time from t

func TimestampWithoutTimeZone

func TimestampWithoutTimeZone(t string, precision int) *time.Time

TimestampWithoutTimeZone creates time from t

func ToJSON

func ToJSON(v interface{}) string

ToJSON converts v into json string

func UInt16Ptr

func UInt16Ptr(i uint16) *uint16

UInt16Ptr returns address of uint16 parameter

func UInt32Ptr

func UInt32Ptr(i uint32) *uint32

UInt32Ptr returns address of uint32 parameter

func UInt64Ptr

func UInt64Ptr(i uint64) *uint64

UInt64Ptr returns address of uint64 parameter

func UInt8Ptr

func UInt8Ptr(i uint8) *uint8

UInt8Ptr returns address of uint8 parameter

func UUIDPtr

func UUIDPtr(u string) *uuid.UUID

UUIDPtr returns address of uuid.UUID

Types

This section is empty.

Jump to

Keyboard shortcuts

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