MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestGetAccountByID_NotFound

Function TestGetAccountByID_NotFound

database/account_test.go:209–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func 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
228func TestGetAllAccounts_QueryError(t *testing.T) {
229 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

GetAccountByIDMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected