(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func TestGetAccountByID_NotFound(t *testing.T) { |
| 210 | db, mock, err := sqlmock.New() |
| 211 | assert.NoError(t, err) |
| 212 | defer func() { _ = db.Close() }() |
| 213 | |
| 214 | ds := Datasource{Conn: db} |
| 215 | |
| 216 | mock.ExpectBegin() |
| 217 | mock.ExpectQuery("SELECT a.account_id, a.name, a.number, a.bank_name"). |
| 218 | WithArgs("acc_notfound"). |
| 219 | WillReturnError(sql.ErrNoRows) |
| 220 | mock.ExpectRollback() |
| 221 | |
| 222 | account, err := ds.GetAccountByID("acc_notfound", []string{}) |
| 223 | assert.Error(t, err) |
| 224 | assert.Nil(t, account) |
| 225 | assert.Contains(t, err.Error(), "not found") |
| 226 | } |
| 227 | |
| 228 | func TestGetAllAccounts_QueryError(t *testing.T) { |
| 229 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected