jet/sqlbuilder/test_utils.go

71 lines
1.8 KiB
Go
Raw Normal View History

package sqlbuilder
2019-05-29 14:03:38 +02:00
import (
"gotest.tools/assert"
"testing"
)
2019-04-07 09:58:12 +02:00
var table1Col1 = NewIntegerColumn("col1", Nullable)
var table1ColInt = NewIntegerColumn("colInt", Nullable)
var table1ColFloat = NewFloatColumn("colFloat", Nullable)
2019-04-07 09:58:12 +02:00
var table1Col3 = NewIntegerColumn("col3", Nullable)
2019-05-29 14:03:38 +02:00
var table1ColTime = NewTimeColumn("colTime", Nullable)
var table1ColBool = NewBoolColumn("colBool", Nullable)
var table1 = NewTable(
2019-03-09 09:52:03 +01:00
"db",
"table1",
table1Col1,
table1ColInt,
table1ColFloat,
table1Col3,
2019-05-29 14:03:38 +02:00
table1ColTime,
table1ColBool)
2019-04-07 09:58:12 +02:00
var table2Col3 = NewIntegerColumn("col3", Nullable)
var table2Col4 = NewIntegerColumn("col4", Nullable)
var table2ColInt = NewIntegerColumn("colInt", Nullable)
var table2ColFloat = NewFloatColumn("colFloat", Nullable)
var table2ColStr = NewStringColumn("colStr", Nullable)
2019-05-29 14:03:38 +02:00
var table2ColBool = NewBoolColumn("colBool", Nullable)
var table2ColTime = NewTimeColumn("colTime", Nullable)
var table2 = NewTable(
2019-03-09 09:52:03 +01:00
"db",
"table2",
table2Col3,
2019-05-29 14:03:38 +02:00
table2Col4,
table2ColInt,
table2ColFloat,
table2ColStr,
2019-05-29 14:03:38 +02:00
table2ColBool,
table2ColTime)
2019-04-07 09:58:12 +02:00
var table3Col1 = NewIntegerColumn("col1", Nullable)
2019-05-29 14:03:38 +02:00
var table3StrCol = NewStringColumn("col2", Nullable)
var table3 = NewTable(
2019-03-09 09:52:03 +01:00
"db",
"table3",
table3Col1,
2019-05-29 14:03:38 +02:00
table3StrCol)
2019-06-04 12:10:23 +02:00
func assertExpressionSerialize(t *testing.T, expression Expression, query string, args ...interface{}) {
2019-05-29 14:03:38 +02:00
out := queryData{}
2019-06-01 18:04:56 +02:00
err := expression.serialize(select_statement, &out)
2019-05-29 14:03:38 +02:00
assert.NilError(t, err)
2019-06-01 18:04:56 +02:00
assert.DeepEqual(t, out.buff.String(), query)
assert.DeepEqual(t, out.args, args)
2019-05-29 14:03:38 +02:00
}
func assertProjectionSerialize(t *testing.T, projection projection, query string, args ...interface{}) {
out := queryData{}
err := projection.serializeForProjection(select_statement, &out)
assert.NilError(t, err)
assert.DeepEqual(t, out.buff.String(), query)
assert.DeepEqual(t, out.args, args)
}