()
| 139 | } |
| 140 | |
| 141 | func ExampleRows_expectToBeClosed() { |
| 142 | db, mock, err := New() |
| 143 | if err != nil { |
| 144 | fmt.Println("failed to open sqlmock database:", err) |
| 145 | } |
| 146 | defer db.Close() |
| 147 | |
| 148 | rows := NewRows([]string{"id", "title"}).AddRow(1, "john") |
| 149 | mock.ExpectQuery("SELECT").WillReturnRows(rows).RowsWillBeClosed() |
| 150 | |
| 151 | db.Query("SELECT") |
| 152 | |
| 153 | if err := mock.ExpectationsWereMet(); err != nil { |
| 154 | fmt.Println("got error:", err) |
| 155 | } |
| 156 | |
| 157 | // Output: got error: expected query rows to be closed, but it was not: ExpectedQuery => expecting Query, QueryContext or QueryRow which: |
| 158 | // - matches sql: 'SELECT' |
| 159 | // - is without arguments |
| 160 | // - should return rows: |
| 161 | // row 0 - [1 john] |
| 162 | } |
| 163 | |
| 164 | func ExampleRows_customDriverValue() { |
| 165 | db, mock, err := New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…