MySQL update statement tests.
This commit is contained in:
parent
a46e8c1c51
commit
7660bdd8b5
12 changed files with 406 additions and 115 deletions
|
|
@ -23,7 +23,7 @@ WHERE link.name IN ('Gmail', 'Outlook');
|
|||
WHERE(Link.Name.IN(String("Gmail"), String("Outlook")))
|
||||
|
||||
testutils.AssertDebugStatementSql(t, deleteStmt, expectedSQL, "Gmail", "Outlook")
|
||||
assertExec(t, deleteStmt, 2)
|
||||
AssertExec(t, deleteStmt, 2)
|
||||
}
|
||||
|
||||
func TestDeleteWithWhereAndReturning(t *testing.T) {
|
||||
|
|
@ -61,7 +61,7 @@ func initForDeleteTest(t *testing.T) {
|
|||
VALUES("www.gmail.com", "Gmail", "Email service developed by Google").
|
||||
VALUES("www.outlook.live.com", "Outlook", "Email service developed by Microsoft")
|
||||
|
||||
assertExec(t, stmt, 2)
|
||||
AssertExec(t, stmt, 2)
|
||||
}
|
||||
|
||||
func TestDeleteQueryContext(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ INSERT INTO test_sample.link VALUES
|
|||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL,
|
||||
100, "http://www.postgresqltutorial.com", "PostgreSQL Tutorial")
|
||||
|
||||
assertExec(t, stmt, 1)
|
||||
AssertExec(t, stmt, 1)
|
||||
}
|
||||
|
||||
func TestInsertModelObject(t *testing.T) {
|
||||
|
|
@ -109,7 +109,7 @@ INSERT INTO test_sample.link (url, name) VALUES
|
|||
|
||||
testutils.AssertDebugStatementSql(t, query, expectedSQL, "http://www.duckduckgo.com", "Duck Duck go")
|
||||
|
||||
assertExec(t, query, 1)
|
||||
AssertExec(t, query, 1)
|
||||
}
|
||||
|
||||
func TestInsertModelObjectEmptyColumnList(t *testing.T) {
|
||||
|
|
@ -131,7 +131,7 @@ INSERT INTO test_sample.link VALUES
|
|||
|
||||
testutils.AssertDebugStatementSql(t, query, expectedSQL, int32(1000), "http://www.duckduckgo.com", "Duck Duck go", nil)
|
||||
|
||||
assertExec(t, query, 1)
|
||||
AssertExec(t, query, 1)
|
||||
}
|
||||
|
||||
func TestInsertModelsObject(t *testing.T) {
|
||||
|
|
@ -166,7 +166,7 @@ INSERT INTO test_sample.link (url, name) VALUES
|
|||
"http://www.google.com", "Google",
|
||||
"http://www.yahoo.com", "Yahoo")
|
||||
|
||||
assertExec(t, stmt, 3)
|
||||
AssertExec(t, stmt, 3)
|
||||
}
|
||||
|
||||
func TestInsertUsingMutableColumns(t *testing.T) {
|
||||
|
|
@ -200,7 +200,7 @@ INSERT INTO test_sample.link (url, name, description) VALUES
|
|||
"http://www.google.com", "Google", nil,
|
||||
"http://www.yahoo.com", "Yahoo", nil)
|
||||
|
||||
assertExec(t, stmt, 4)
|
||||
AssertExec(t, stmt, 4)
|
||||
}
|
||||
|
||||
func TestInsertQuery(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ WHERE link.name = 'Bing';
|
|||
`
|
||||
testutils.AssertDebugStatementSql(t, query, expectedSQL, "Bong", "http://bong.com", "Bing")
|
||||
|
||||
assertExec(t, query, 1)
|
||||
AssertExec(t, query, 1)
|
||||
|
||||
links := []model.Link{}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ WHERE link.name = 'Bing';
|
|||
|
||||
testutils.AssertDebugStatementSql(t, query, expectedSQL, "Bong", "Bing", "Bing")
|
||||
|
||||
assertExec(t, query, 1)
|
||||
AssertExec(t, query, 1)
|
||||
}
|
||||
|
||||
func TestUpdateAndReturning(t *testing.T) {
|
||||
|
|
@ -129,7 +129,7 @@ WHERE link.id = 0;
|
|||
`
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, int64(0), int64(0))
|
||||
|
||||
assertExec(t, stmt, 1)
|
||||
AssertExec(t, stmt, 1)
|
||||
}
|
||||
|
||||
func TestUpdateWithInvalidSelect(t *testing.T) {
|
||||
|
|
@ -178,7 +178,7 @@ WHERE link.id = 201;
|
|||
`
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, int32(201), "http://www.duckduckgo.com", "DuckDuckGo", nil, int64(201))
|
||||
|
||||
assertExec(t, stmt, 1)
|
||||
AssertExec(t, stmt, 1)
|
||||
}
|
||||
|
||||
func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
|
||||
|
|
@ -205,7 +205,7 @@ WHERE link.id = 201;
|
|||
`
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, nil, "DuckDuckGo", "http://www.duckduckgo.com", int64(201))
|
||||
|
||||
assertExec(t, stmt, 1)
|
||||
AssertExec(t, stmt, 1)
|
||||
}
|
||||
|
||||
func TestUpdateWithInvalidModelData(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func assertExec(t *testing.T, stmt jet.Statement, rowsAffected int64) {
|
||||
func AssertExec(t *testing.T, stmt jet.Statement, rowsAffected int64) {
|
||||
res, err := stmt.Exec(db)
|
||||
|
||||
assert.NilError(t, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue