jet/sqlbuilder/test_utils.go
2019-06-04 11:52:37 +02:00

70 lines
1.8 KiB
Go

package sqlbuilder
import (
"gotest.tools/assert"
"testing"
)
var table1Col1 = NewIntegerColumn("col1", Nullable)
var table1ColInt = NewIntegerColumn("colInt", Nullable)
var table1ColFloat = NewFloatColumn("colFloat", Nullable)
var table1Col3 = NewIntegerColumn("col3", Nullable)
var table1ColTime = NewTimeColumn("colTime", Nullable)
var table1ColBool = NewBoolColumn("colBool", Nullable)
var table1 = NewTable(
"db",
"table1",
table1Col1,
table1ColInt,
table1ColFloat,
table1Col3,
table1ColTime,
table1ColBool)
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)
var table2ColBool = NewBoolColumn("colBool", Nullable)
var table2ColTime = NewTimeColumn("colTime", Nullable)
var table2 = NewTable(
"db",
"table2",
table2Col3,
table2Col4,
table2ColInt,
table2ColFloat,
table2ColStr,
table2ColBool,
table2ColTime)
var table3Col1 = NewIntegerColumn("col1", Nullable)
var table3StrCol = NewStringColumn("col2", Nullable)
var table3 = NewTable(
"db",
"table3",
table3Col1,
table3StrCol)
func assertExpressionSerialize(t *testing.T, expression expression, query string, args ...interface{}) {
out := queryData{}
err := expression.serialize(select_statement, &out)
assert.NilError(t, err)
assert.DeepEqual(t, out.buff.String(), query)
assert.DeepEqual(t, out.args, args)
}
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)
}