package fees import "testing" func TestCalculateFee(t *testing.T) { t.Parallel() // mustRate returns the configured rate for a month that must be in the map. // It panics immediately if the month is absent — so if a rate entry is ever // removed, the test fails loudly rather than silently comparing against // Go's zero value. mustRate := func(month string) int { r, ok := AdultFeeMonthlyRate[month] if !ok { panic("test month not in AdultFeeMonthlyRate: " + month) } return r } tests := []struct { name string count int month string want int }{ // Zero attendance always returns 0. {"zero short-circuits", 0, "2026-05", 0}, {"zero empty month", 0, "", 0}, // Single practice returns AdultFeeSingle regardless of month. {"single practice", 1, "2026-05", AdultFeeSingle}, {"single ignores monthKey", 1, "unknown", AdultFeeSingle}, // Two+ practices for a configured month: must use the map value, not the default. // Expected values are read from AdultFeeMonthlyRate so this test stays correct // when rates are updated — the assertion verifies dispatch logic, not rate values. {"two practices configured month", 2, "2026-05", mustRate("2026-05")}, {"two practices reduced march", 2, "2026-03", mustRate("2026-03")}, {"two practices early season", 2, "2025-09", mustRate("2025-09")}, {"high count same as two", 5, "2026-05", mustRate("2026-05")}, // Two+ practices for an unknown/future month: must fall back to AdultFeeDefault. {"unknown future month falls back", 2, "2027-01", AdultFeeDefault}, {"empty month falls back", 2, "", AdultFeeDefault}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel() got := CalculateFee(tc.count, tc.month) if got != tc.want { t.Errorf("CalculateFee(%d, %q) = %d, want %d", tc.count, tc.month, got, tc.want) } }) } }