1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2025-06-12 21:47:29 +02:00

Rows interface to allow building rows in different ways

This commit is contained in:
gedi
2014-02-14 00:14:32 +02:00
parent 008d8847b2
commit bdba0bb0c6
4 changed files with 80 additions and 16 deletions

View File

@ -13,7 +13,7 @@ func TestMockQuery(t *testing.T) {
t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
}
rs := RowsFromCSVString([]string{"id", "title"}, "5,hello world")
rs := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
WithArgs(5).
@ -153,12 +153,12 @@ func TestPreparedQueryExecutions(t *testing.T) {
t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
}
rs1 := RowsFromCSVString([]string{"id", "title"}, "5,hello world")
rs1 := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
WithArgs(5).
WillReturnRows(rs1)
rs2 := RowsFromCSVString([]string{"id", "title"}, "2,whoop")
rs2 := NewRows([]string{"id", "title"}).FromCSVString("2,whoop")
ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
WithArgs(2).
WillReturnRows(rs2)
@ -237,7 +237,7 @@ func TestWrongExpectations(t *testing.T) {
ExpectBegin()
rs1 := RowsFromCSVString([]string{"id", "title"}, "5,hello world")
rs1 := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
WithArgs(5).
WillReturnRows(rs1)