SP12893678 commented on code in PR #888:
URL: https://github.com/apache/yunikorn-core/pull/888#discussion_r1635169268
##########
pkg/common/utils_test.go:
##########
@@ -380,3 +383,127 @@ func TestGetConfigurationInt(t *testing.T) {
})
}
}
+
+func TestZeroTimeInUnixNano(t *testing.T) {
+ tests := []struct {
+ name string
+ input time.Time
+ expected *int64
+ }{
+ {
+ name: "zero time",
+ input: time.Time{},
+ expected: nil,
+ },
+ {
+ name: "non-zero time",
+ input: time.Date(2024, time.June, 6, 0, 0, 0, 0,
time.UTC),
+ expected: func() *int64 {
+ tInt := time.Date(2024, time.June, 6, 0, 0, 0,
0, time.UTC).UnixNano()
+ return &tInt
+ }(),
+ },
+ {
+ name: "time in different timezone",
+ input: time.Date(2024, time.June, 6, 0, 0, 0, 0,
time.FixedZone("UTC+8", 8*60*60)),
+ expected: func() *int64 {
+ tInt := time.Date(2024, time.June, 6, 0, 0, 0,
0, time.FixedZone("UTC+8", 8*60*60)).UnixNano()
+ return &tInt
+ }(),
+ },
+ }
+
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ result := ZeroTimeInUnixNano(tc.input)
+ if tc.expected == nil {
+ assert.Equal(t, tc.expected, result)
+ } else {
+ assert.Equal(t, *tc.expected, *result)
+ }
+ })
+ }
Review Comment:
Sure. It looks better now!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]