package fees import "testing" func TestCalculateJuniorFee(t *testing.T) { t.Parallel() // mustRate returns the configured rate for a month that must be in the map. // Panics immediately if the month is absent so a removed entry causes a loud // failure rather than a silent comparison against Go's zero value. mustRate := func(month string) Expected { r, ok := JuniorFeeMonthlyRate[month] if !ok { panic("test month not in JuniorFeeMonthlyRate: " + month) } return Expected{Value: r} } tests := []struct { name string count int month string want Expected }{ // Zero attendance always returns 0. {"zero short-circuits", 0, "2026-05", Expected{Value: 0}}, {"zero empty month", 0, "", Expected{Value: 0}}, // Single practice returns the Unknown sentinel regardless of month. {"single practice sentinel", 1, "2026-05", Expected{Unknown: true}}, {"single ignores monthKey", 1, "unknown", Expected{Unknown: true}}, // Two+ practices for a configured month: must use the map value, not the default. {"two practices unconfigured month", 2, "2026-05", Expected{Value: JuniorFeeDefault}}, {"two practices reduced sept", 2, "2025-09", mustRate("2025-09")}, {"two practices reduced march", 2, "2026-03", mustRate("2026-03")}, {"high count same as two", 5, "2025-09", mustRate("2025-09")}, // Two+ practices for an unknown/future month: must fall back to JuniorFeeDefault. {"unknown future month falls back", 2, "2027-01", Expected{Value: JuniorFeeDefault}}, {"empty month falls back", 2, "", Expected{Value: JuniorFeeDefault}}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel() got := CalculateJuniorFee(tc.count, tc.month) if got != tc.want { t.Errorf("CalculateJuniorFee(%d, %q) = %+v, want %+v", tc.count, tc.month, got, tc.want) } }) } }