Test utils reuse.
This commit is contained in:
parent
74288d5418
commit
d3d00910aa
16 changed files with 200 additions and 221 deletions
|
|
@ -6,21 +6,21 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
//TODO:
|
||||
//
|
||||
//func TestInvalidInsert(t *testing.T) {
|
||||
// assertStatementErr(t, table1.INSERT(table1Col1), "jet: no row values or query specified")
|
||||
// assertStatementErr(t, table1.INSERT(nil).VALUES(1), "jet: nil column in columns list")
|
||||
// assertStatementSqlErr(t, table1.INSERT(table1Col1), "jet: no row values or query specified")
|
||||
// assertStatementSqlErr(t, table1.INSERT(nil).VALUES(1), "jet: nil column in columns list")
|
||||
//}
|
||||
|
||||
func TestInsertNilValue(t *testing.T) {
|
||||
assertStatement(t, table1.INSERT(table1Col1).VALUES(nil), `
|
||||
assertStatementSql(t, table1.INSERT(table1Col1).VALUES(nil), `
|
||||
INSERT INTO db.table1 (col1) VALUES
|
||||
(?);
|
||||
`, nil)
|
||||
}
|
||||
|
||||
func TestInsertSingleValue(t *testing.T) {
|
||||
assertStatement(t, table1.INSERT(table1Col1).VALUES(1), `
|
||||
assertStatementSql(t, table1.INSERT(table1Col1).VALUES(1), `
|
||||
INSERT INTO db.table1 (col1) VALUES
|
||||
(?);
|
||||
`, int(1))
|
||||
|
|
@ -29,7 +29,7 @@ INSERT INTO db.table1 (col1) VALUES
|
|||
func TestInsertWithColumnList(t *testing.T) {
|
||||
columnList := ColumnList(table3ColInt, table3StrCol)
|
||||
|
||||
assertStatement(t, table3.INSERT(columnList).VALUES(1, 3), `
|
||||
assertStatementSql(t, table3.INSERT(columnList).VALUES(1, 3), `
|
||||
INSERT INTO db.table3 (col_int, col2) VALUES
|
||||
(?, ?);
|
||||
`, 1, 3)
|
||||
|
|
@ -38,14 +38,14 @@ INSERT INTO db.table3 (col_int, col2) VALUES
|
|||
func TestInsertDate(t *testing.T) {
|
||||
date := time.Date(1999, 1, 2, 3, 4, 5, 0, time.UTC)
|
||||
|
||||
assertStatement(t, table1.INSERT(table1ColTimestamp).VALUES(date), `
|
||||
assertStatementSql(t, table1.INSERT(table1ColTimestamp).VALUES(date), `
|
||||
INSERT INTO db.table1 (col_timestamp) VALUES
|
||||
(?);
|
||||
`, date)
|
||||
}
|
||||
|
||||
func TestInsertMultipleValues(t *testing.T) {
|
||||
assertStatement(t, table1.INSERT(table1Col1, table1ColFloat, table1Col3).VALUES(1, 2, 3), `
|
||||
assertStatementSql(t, table1.INSERT(table1Col1, table1ColFloat, table1Col3).VALUES(1, 2, 3), `
|
||||
INSERT INTO db.table1 (col1, col_float, col3) VALUES
|
||||
(?, ?, ?);
|
||||
`, 1, 2, 3)
|
||||
|
|
@ -57,7 +57,7 @@ func TestInsertMultipleRows(t *testing.T) {
|
|||
VALUES(11, 22).
|
||||
VALUES(111, 222)
|
||||
|
||||
assertStatement(t, stmt, `
|
||||
assertStatementSql(t, stmt, `
|
||||
INSERT INTO db.table1 (col1, col_float) VALUES
|
||||
(?, ?),
|
||||
(?, ?),
|
||||
|
|
@ -88,7 +88,7 @@ INSERT INTO db.table1 (col1, col_float) VALUES
|
|||
(?, ?);
|
||||
`
|
||||
|
||||
assertStatement(t, stmt, expectedSQL, int(1), float64(1.11), int(1), float64(1.11))
|
||||
assertStatementSql(t, stmt, expectedSQL, int(1), float64(1.11), int(1), float64(1.11))
|
||||
}
|
||||
|
||||
func TestInsertValuesFromModelColumnMismatch(t *testing.T) {
|
||||
|
|
@ -130,5 +130,5 @@ INSERT INTO db.table1 (col1, col_float) VALUES
|
|||
(DEFAULT, ?);
|
||||
`
|
||||
|
||||
assertStatement(t, stmt, expectedSQL, "two")
|
||||
assertStatementSql(t, stmt, expectedSQL, "two")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue