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

Function TestUpdateLedger_NotFound

database/ledger_test.go:288–304  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

286}
287
288func TestUpdateLedger_NotFound(t *testing.T) {
289 db, mock, err := sqlmock.New()
290 assert.NoError(t, err)
291 defer func() { _ = db.Close() }()
292
293 ds := Datasource{Conn: db}
294
295 mock.ExpectQuery("SELECT ledger_id, name, created_at, meta_data FROM ledgerforge.ledgers WHERE ledger_id = ?").
296 WithArgs("ldg_notfound").
297 WillReturnError(sql.ErrNoRows)
298
299 _, err = ds.UpdateLedger("ldg_notfound", "New Name")
300 assert.Error(t, err)
301 apiErr, ok := err.(apierror.APIError)
302 assert.True(t, ok)
303 assert.Equal(t, apierror.ErrNotFound, apiErr.Code)
304}
305
306func TestUpdateLedger_UniqueViolation(t *testing.T) {
307 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

UpdateLedgerMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected