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

Function TestTakeBalanceSnapshots_Error

database/balance_test.go:1843–1864  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1841}
1842
1843func TestTakeBalanceSnapshots_Error(t *testing.T) {
1844 db, mock, err := sqlmock.New()
1845 assert.NoError(t, err)
1846 defer func() { _ = db.Close() }()
1847
1848 ds := Datasource{Conn: db}
1849 ctx := context.Background()
1850
1851 mock.ExpectQuery(regexp.QuoteMeta("SELECT ledgerforge.take_daily_balance_snapshots_batched($1)")).
1852 WithArgs(100).
1853 WillReturnError(sql.ErrConnDone)
1854
1855 count, err := ds.TakeBalanceSnapshots(ctx, 100)
1856 assert.Error(t, err)
1857 assert.Equal(t, 0, count)
1858 apiErr, ok := err.(apierror.APIError)
1859 assert.True(t, ok)
1860 assert.Equal(t, apierror.ErrInternalServer, apiErr.Code)
1861
1862 err = mock.ExpectationsWereMet()
1863 assert.NoError(t, err)
1864}
1865
1866func TestGetMostRecentSnapshot_Found(t *testing.T) {
1867 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

TakeBalanceSnapshotsMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected