MCPcopy
hub / github.com/andeya/pholcus / TestTable_SelectAll_WithMock

Function TestTable_SelectAll_WithMock

common/mysql/mysql_test.go:294–314  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292}
293
294func TestTable_SelectAll_WithMock(t *testing.T) {
295 _, mock, teardown := setupMockDB(t)
296 defer teardown()
297
298 rows := sqlmock.NewRows([]string{"id", "name"}).AddRow(1, "a")
299 mock.ExpectQuery("SELECT \\* FROM `users`").
300 WillReturnRows(rows)
301
302 tbl := New().Unwrap().SetTableName("users")
303 r := tbl.SelectAll()
304 if r.IsErr() {
305 t.Errorf("SelectAll() = %v", r.UnwrapErr())
306 return
307 }
308 rs := r.Unwrap()
309 defer rs.Close()
310 if err := mock.ExpectationsWereMet(); err != nil {
311 t.Errorf("mock: %v", err)
312 }
313 _ = rs
314}
315
316func TestTable_Create_ExecError(t *testing.T) {
317 _, mock, teardown := setupMockDB(t)

Callers

nothing calls this directly

Calls 7

setupMockDBFunction · 0.85
AddRowMethod · 0.80
SetTableNameMethod · 0.80
UnwrapMethod · 0.80
SelectAllMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected