@@ -516,22 +516,20 @@ func TestSchedulesOverlap(t *testing.T) {
516
516
func TestValidateSchedules (t * testing.T ) {
517
517
t .Parallel ()
518
518
testCases := []struct {
519
- name string
520
- schedules []string
521
- expectErr bool
519
+ name string
520
+ schedules []string
521
+ expectedErrMsg string
522
522
}{
523
523
// Basic validation
524
524
{
525
525
name : "Empty schedules" ,
526
526
schedules : []string {},
527
- expectErr : false ,
528
527
},
529
528
{
530
529
name : "Single valid schedule" ,
531
530
schedules : []string {
532
531
"* 9-18 * * 1-5" ,
533
532
},
534
- expectErr : false ,
535
533
},
536
534
537
535
// Non-overlapping schedules
@@ -541,15 +539,13 @@ func TestValidateSchedules(t *testing.T) {
541
539
"* 9-12 * * 1-5" ,
542
540
"* 13-18 * * 1-5" ,
543
541
},
544
- expectErr : false ,
545
542
},
546
543
{
547
544
name : "Multiple valid non-overlapping schedules" ,
548
545
schedules : []string {
549
546
"* 9-18 * * 1-5" ,
550
547
"* 9-13 * * 6,0" ,
551
548
},
552
- expectErr : false ,
553
549
},
554
550
555
551
// Overlapping schedules
@@ -559,7 +555,7 @@ func TestValidateSchedules(t *testing.T) {
559
555
"* 9-14 * * 1-5" ,
560
556
"* 12-18 * * 1-5" ,
561
557
},
562
- expectErr : true ,
558
+ expectedErrMsg : "schedules overlap: * 9-14 * * 1-5 and * 12-18 * * 1-5" ,
563
559
},
564
560
{
565
561
name : "Three schedules with only second and third overlapping" ,
@@ -568,7 +564,7 @@ func TestValidateSchedules(t *testing.T) {
568
564
"* 12-18 * * 1-5" , // 12PM-6PM
569
565
"* 15-20 * * 1-5" , // 3PM-8PM (overlaps with second)
570
566
},
571
- expectErr : true ,
567
+ expectedErrMsg : "schedules overlap: * 12-18 * * 1-5 and * 15-20 * * 1-5" ,
572
568
},
573
569
}
574
570
@@ -577,8 +573,9 @@ func TestValidateSchedules(t *testing.T) {
577
573
t .Run (testCase .name , func (t * testing.T ) {
578
574
t .Parallel ()
579
575
err := helpers .ValidateSchedules (testCase .schedules )
580
- if testCase .expectErr {
576
+ if testCase .expectedErrMsg != "" {
581
577
require .Error (t , err )
578
+ require .Contains (t , err .Error (), testCase .expectedErrMsg )
582
579
} else {
583
580
require .NoError (t , err )
584
581
}
0 commit comments