jet/postgres/utils_test.go

89 lines
2.4 KiB
Go
Raw Normal View History

2019-07-31 18:43:54 +02:00
package postgres
import (
"testing"
2019-08-03 14:10:47 +02:00
"github.com/go-jet/jet/internal/jet"
2019-08-12 12:11:16 +02:00
"github.com/go-jet/jet/internal/testutils"
2019-07-31 18:43:54 +02:00
)
var table1Col1 = IntegerColumn("col1")
var table1ColInt = IntegerColumn("col_int")
var table1ColFloat = FloatColumn("col_float")
var table1Col3 = IntegerColumn("col3")
var table1ColTime = TimeColumn("col_time")
var table1ColTimez = TimezColumn("col_timez")
var table1ColTimestamp = TimestampColumn("col_timestamp")
var table1ColTimestampz = TimestampzColumn("col_timestampz")
var table1ColBool = BoolColumn("col_bool")
var table1ColDate = DateColumn("col_date")
2019-08-03 14:10:47 +02:00
var table1 = NewTable(
2019-07-31 18:43:54 +02:00
"db",
"table1",
table1Col1,
table1ColInt,
table1ColFloat,
table1Col3,
table1ColTime,
table1ColTimez,
table1ColBool,
table1ColDate,
table1ColTimestamp,
table1ColTimestampz,
)
var table2Col3 = IntegerColumn("col3")
var table2Col4 = IntegerColumn("col4")
var table2ColInt = IntegerColumn("col_int")
var table2ColFloat = FloatColumn("col_float")
var table2ColStr = StringColumn("col_str")
var table2ColBool = BoolColumn("col_bool")
var table2ColTime = TimeColumn("col_time")
var table2ColTimez = TimezColumn("col_timez")
var table2ColTimestamp = TimestampColumn("col_timestamp")
var table2ColTimestampz = TimestampzColumn("col_timestampz")
var table2ColDate = DateColumn("col_date")
2019-08-03 14:10:47 +02:00
var table2 = NewTable(
2019-07-31 18:43:54 +02:00
"db",
"table2",
table2Col3,
table2Col4,
table2ColInt,
table2ColFloat,
table2ColStr,
table2ColBool,
table2ColTime,
table2ColTimez,
table2ColDate,
table2ColTimestamp,
table2ColTimestampz,
)
var table3Col1 = IntegerColumn("col1")
var table3ColInt = IntegerColumn("col_int")
var table3StrCol = StringColumn("col2")
2019-08-03 14:10:47 +02:00
var table3 = NewTable(
2019-07-31 18:43:54 +02:00
"db",
"table3",
table3Col1,
table3ColInt,
table3StrCol)
2019-08-03 14:10:47 +02:00
func assertSerialize(t *testing.T, clause jet.Serializer, query string, args ...interface{}) {
2019-08-12 12:11:16 +02:00
testutils.AssertClauseSerialize(t, Dialect, clause, query, args...)
2019-08-03 14:10:47 +02:00
}
2019-08-11 09:52:02 +02:00
func assertClauseSerializeErr(t *testing.T, clause jet.Serializer, errString string) {
2019-08-12 12:11:16 +02:00
testutils.AssertClauseSerializeErr(t, Dialect, clause, errString)
2019-08-03 14:10:47 +02:00
}
func assertProjectionSerialize(t *testing.T, projection jet.Projection, query string, args ...interface{}) {
2019-08-12 12:11:16 +02:00
testutils.AssertProjectionSerialize(t, Dialect, projection, query, args...)
2019-08-03 14:10:47 +02:00
}
2019-08-12 12:11:16 +02:00
var assertStatementSql = testutils.AssertStatementSql
var assertStatementSqlErr = testutils.AssertStatementSqlErr
var assertPanicErr = testutils.AssertPanicErr