Skip to content

Commit

Permalink
test: add tests for invalid schedule and duration
Browse files Browse the repository at this point in the history
Signed-off-by: daengdaengLee <gunho1020@gmail.com>
  • Loading branch information
daengdaengLee committed Oct 3, 2024
1 parent e3da773 commit d717910
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions pkg/apis/application/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,24 @@ func TestSyncWindows_Active(t *testing.T) {
matchingIndex: 0,
expectedLength: 1,
},
{
name: "MatchNone-InvalidSchedule",
syncWindow: SyncWindows{
syncWindow("allow", "* 10 * * 7", "3h", ""),
syncWindow("allow", "* 11 * * 7", "3h", ""),
},
currentTime: timeWithHour(12, time.UTC),
expectedLength: 0,
},
{
name: "MatchNone-InvalidDuration",
syncWindow: SyncWindows{
syncWindow("allow", "* 10 * * *", "3a", ""),
syncWindow("allow", "* 11 * * *", "3a", ""),
},
currentTime: timeWithHour(12, time.UTC),
expectedLength: 0,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -2085,6 +2103,22 @@ func TestSyncWindows_InactiveAllows(t *testing.T) {
matchingIndex: 0,
expectedLength: 1,
},
{
name: "MatchNone-InvalidSchedule",
syncWindow: SyncWindows{
syncWindow("allow", "* 10 * * 7", "2h", ""),
},
currentTime: timeWithHour(17, time.UTC),
expectedLength: 0,
},
{
name: "MatchNone-InvalidDuration",
syncWindow: SyncWindows{
syncWindow("allow", "* 10 * * *", "2a", ""),
},
currentTime: timeWithHour(17, time.UTC),
expectedLength: 0,
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -2639,6 +2673,30 @@ func TestSyncWindow_Active(t *testing.T) {
currentTime: timeWithHour(13-4, utcM4Zone),
expectedResult: false,
},
{
name: "Allow-inactive-InvalidSchedule",
syncWindow: syncWindow("allow", "* 10 * * 7", "2h"),
currentTime: timeWithHour(11, time.UTC),
expectedResult: false,
},
{
name: "Deny-inactive-InvalidSchedule",
syncWindow: syncWindow("deny", "* 10 * * 7", "2h"),
currentTime: timeWithHour(11, time.UTC),
expectedResult: false,
},
{
name: "Allow-inactive-InvalidDuration",
syncWindow: syncWindow("allow", "* 10 * * *", "2a"),
currentTime: timeWithHour(11, time.UTC),
expectedResult: false,
},
{
name: "Deny-inactive-InvalidDuration",
syncWindow: syncWindow("deny", "* 10 * * *", "2a"),
currentTime: timeWithHour(11, time.UTC),
expectedResult: false,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit d717910

Please sign in to comment.