Skip to content

Commit 0228e3c

Browse files
committed
fix tests
1 parent 66ce47e commit 0228e3c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

service/sharddistributor/store/etcd/etcdtypes/time.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ func (t Time) ToTime() time.Time {
2222
}
2323

2424
// ToTimePtr converts Time back to *time.Time.
25-
func (t Time) ToTimePtr() *time.Time {
26-
tt := time.Time(t)
25+
func (t *Time) ToTimePtr() *time.Time {
26+
if t == nil {
27+
return nil
28+
}
29+
tt := time.Time(*t)
2730
return &tt
2831
}
2932

service/sharddistributor/store/etcd/etcdtypes/time_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ func TestTimeToTimePtr_NilInput_ReturnsNil(t *testing.T) {
2121
require.Nil(t, result)
2222
}
2323

24-
func TestTimeToTimePtr_ValidInput_ReturnsPointer(t *testing.T) {
24+
func TestTimeToTimePtr(t *testing.T) {
2525
now := time.Now()
2626
result := ToTimePtr(&now)
2727
require.NotNil(t, result)
2828
require.Equal(t, Time(now), *result)
2929
}
3030

31-
func TestTimeToTimePtr_ConvertsBackToTimePtr(t *testing.T) {
32-
now := time.Now()
33-
wrapped := Time(now)
34-
result := wrapped.ToTimePtr()
35-
require.NotNil(t, result)
36-
require.Equal(t, now, *result)
31+
func TestTimeToTimePtr_Nil(t *testing.T) {
32+
result := ToTimePtr(nil)
33+
require.Nil(t, result)
3734
}
3835

3936
func TestTimeMarshalJSON(t *testing.T) {

0 commit comments

Comments
 (0)