test: expand handler tests to 53.4% coverage
Some checks failed
CI / lint-test (push) Failing after 1s
Some checks failed
CI / lint-test (push) Failing after 1s
This commit is contained in:
@@ -64,3 +64,34 @@ func TestCalculateInterestForDeposit_ExpiredDeposit(t *testing.T) {
|
||||
t.Errorf("expected empty result for expired deposit, got %q", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalculateInterestForDeposit_WrongDay(t *testing.T) {
|
||||
s := &InterestService{}
|
||||
// Start date with day that is NOT today
|
||||
// We pick a day that will never be today unless very lucky
|
||||
today := time.Now()
|
||||
// Pick a start day that differs from today
|
||||
startDay := today.Day() + 1
|
||||
if startDay > 28 {
|
||||
startDay = 1
|
||||
}
|
||||
startDate := time.Date(today.Year()-1, today.Month(), startDay, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
deposit := &model.SavingsCategory{
|
||||
Name: "Test",
|
||||
IsDeposit: true,
|
||||
InterestRate: 12,
|
||||
DepositStartDate: sql.NullTime{
|
||||
Time: startDate,
|
||||
Valid: true,
|
||||
},
|
||||
}
|
||||
// Should return empty string (not today's interest day) — no DB call
|
||||
result, err := s.CalculateInterestForDeposit(deposit)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if result != "" {
|
||||
t.Errorf("expected empty result for non-interest day, got %q", result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user