func TestInsertExpense(t *testing.T) {
	tx := BeginTx()
	defer tx.Rollback()

	expense := model.NewExpense()
	expense.Description = "some description"
	expense.Amount = 23
	err := db.InsertExpense(tx, expense)
	assert.MustBeNil(t, err)

	var amount int
	var description string
	row := tx.QueryRow("SELECT description, amount FROM expenses")
	err = row.Scan(&description, &amount)

	assert.MustBeNil(t, err)
	assert.MustBeEqual(t, "some description", description)
	assert.MustBeEqual(t, 23, amount)
}
func TestListExpenses(t *testing.T) {
	tx := dbtest.BeginTx()
	defer tx.Rollback()

	_, err := fabricate.Expense(tx).Description("Important Expense").Exec()
	assert.MustBeNil(t, err)

	expenses, err := service.ListExpenses(logger.Discard, tx)
	assert.MustBeNil(t, err)
	assert.MustBeEqual(t, 1, len(expenses))
	assert.Equal(t, "Important Expense", expenses[0].Description)
}
func TestCreateExpense_Validation(t *testing.T) {
	tx := dbtest.BeginTx()
	defer tx.Rollback()

	_, err := service.CreateExpense(logger.Discard, tx, service.CreateExpenseParams{
		Description: "",
		Amount:      0,
	})

	assert.MustBeEqual(t, "ValidationError: Description: must be present, Amount: must be greater than 0", err.Error())

	cnt, err := db.CountExpenses(tx)
	assert.MustBeNil(t, err)
	assert.Equal(t, 0, cnt)
}