mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add more test cases for *monthly_estimated
This commit is contained in:
committed by
Dan Christian Bogos
parent
cdec2f4148
commit
ca3d5c0276
@@ -131,7 +131,7 @@ func (at *ActionTiming) GetNextStartTime(t1 time.Time) (t time.Time) {
|
||||
if i.Timing.ID == utils.MetaMonthlyEstimated {
|
||||
clnRITiming := at.Timing.Timing.Clone()
|
||||
mnt := t1.Month()
|
||||
if t1.Day() > clnRITiming.MonthDays[0] {
|
||||
if t1.Day() >= clnRITiming.MonthDays[0] {
|
||||
mnt++
|
||||
if mnt == 13 { // special case in case of december next month is January
|
||||
mnt = 1
|
||||
|
||||
@@ -323,4 +323,28 @@ func TestActionTimingGetNextStartTime(t *testing.T) {
|
||||
if st := at.GetNextStartTime(t1); !st.Equal(exp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", exp, st)
|
||||
}
|
||||
|
||||
t1 = time.Date(2020, 2, 17, 14, 25, 0, 0, time.UTC)
|
||||
at = &ActionTiming{
|
||||
Timing: &RateInterval{
|
||||
Timing: &RITiming{
|
||||
ID: utils.MetaMonthlyEstimated,
|
||||
MonthDays: utils.MonthDays{17},
|
||||
StartTime: "15:00:00"}}}
|
||||
exp = time.Date(2020, 2, 17, 15, 0, 0, 0, time.UTC)
|
||||
if st := at.GetNextStartTime(t1); !st.Equal(exp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", exp, st)
|
||||
}
|
||||
|
||||
t1 = time.Date(2020, 2, 17, 15, 25, 0, 0, time.UTC)
|
||||
at = &ActionTiming{
|
||||
Timing: &RateInterval{
|
||||
Timing: &RITiming{
|
||||
ID: utils.MetaMonthlyEstimated,
|
||||
MonthDays: utils.MonthDays{17},
|
||||
StartTime: "10:00:00"}}}
|
||||
exp = time.Date(2020, 3, 17, 10, 0, 0, 0, time.UTC)
|
||||
if st := at.GetNextStartTime(t1); !st.Equal(exp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", exp, st)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user