(t *testing.T)
| 1841 | } |
| 1842 | |
| 1843 | func 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 | |
| 1866 | func TestGetMostRecentSnapshot_Found(t *testing.T) { |
| 1867 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected