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 7, 2024
1 parent 5d360a5 commit 406527f
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 @@ -1926,6 +1926,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 @@ -2099,6 +2117,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 @@ -2653,6 +2687,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 406527f

Please sign in to comment.