MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / TestUpdateLedgerNotFound

Function TestUpdateLedgerNotFound

ledger_test.go:202–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

200}
201
202func TestUpdateLedgerNotFound(t *testing.T) {
203 datasource, mock, err := newTestDataSource()
204 if err != nil {
205 t.Fatalf("Error creating test data source: %s", err)
206 }
207
208 d, err := NewLedgerForge(datasource)
209 if err != nil {
210 t.Fatalf("Error creating LedgerForge instance: %s", err)
211 }
212
213 testID := "ldg_nonexistent"
214 newName := "Updated Ledger"
215
216 // Mock the GetLedgerByID call to return no rows (ledger not found)
217 mock.ExpectQuery("SELECT ledger_id, name, created_at, meta_data FROM ledgerforge.ledgers WHERE ledger_id =").
218 WithArgs(testID).
219 WillReturnError(sql.ErrNoRows)
220
221 result, err := d.UpdateLedger(testID, newName)
222
223 assert.Error(t, err)
224 assert.Nil(t, result)
225
226 if err := mock.ExpectationsWereMet(); err != nil {
227 t.Errorf("there were unfulfilled expectations: %s", err)
228 }
229}

Callers

nothing calls this directly

Calls 4

UpdateLedgerMethod · 0.95
newTestDataSourceFunction · 0.85
NewLedgerForgeFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected