Add more test cases for *monthly_estimated

This commit is contained in:
TeoV
2020-07-24 09:11:12 +03:00
committed by Dan Christian Bogos
parent cdec2f4148
commit ca3d5c0276
2 changed files with 25 additions and 1 deletions

View File

@@ -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

View File

@@ -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)
}
}