@@ -676,3 +676,51 @@ func TestJob_PanicOccurred(t *testing.T) {
676
676
close (gotCh )
677
677
close (errCh )
678
678
}
679
+
680
+ func TestTimeFromAtTime (t * testing.T ) {
681
+ testTimeUTC := time .Date (0 , 0 , 0 , 1 , 1 , 1 , 0 , time .UTC )
682
+ cst , err := time .LoadLocation ("America/Chicago" )
683
+ require .NoError (t , err )
684
+ testTimeCST := time .Date (0 , 0 , 0 , 1 , 1 , 1 , 0 , cst )
685
+
686
+ tests := []struct {
687
+ name string
688
+ at AtTime
689
+ loc * time.Location
690
+ expectedTime time.Time
691
+ expectedStr string
692
+ }{
693
+ {
694
+ "UTC" ,
695
+ NewAtTime (
696
+ uint (testTimeUTC .Hour ()),
697
+ uint (testTimeUTC .Minute ()),
698
+ uint (testTimeUTC .Second ()),
699
+ ),
700
+ time .UTC ,
701
+ testTimeUTC ,
702
+ "01:01:01" ,
703
+ },
704
+ {
705
+ "CST" ,
706
+ NewAtTime (
707
+ uint (testTimeCST .Hour ()),
708
+ uint (testTimeCST .Minute ()),
709
+ uint (testTimeCST .Second ()),
710
+ ),
711
+ cst ,
712
+ testTimeCST ,
713
+ "01:01:01" ,
714
+ },
715
+ }
716
+
717
+ for _ , tt := range tests {
718
+ t .Run (tt .name , func (t * testing.T ) {
719
+ result := TimeFromAtTime (tt .at , tt .loc )
720
+ assert .Equal (t , tt .expectedTime , result )
721
+
722
+ resultFmt := result .Format ("15:04:05" )
723
+ assert .Equal (t , tt .expectedStr , resultFmt )
724
+ })
725
+ }
726
+ }
0 commit comments