-
Notifications
You must be signed in to change notification settings - Fork 191
/
issues_test.go
43 lines (37 loc) · 960 Bytes
/
issues_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dump_test
import (
"fmt"
"reflect"
"testing"
"time"
"github.com/gookit/goutil/dump"
)
func isTimeType(v interface{}) bool {
return reflect.TypeOf(v).ConvertibleTo(reflect.TypeOf(time.Time{}))
}
// https://github.com/gookit/goutil/issues/200
func TestIssues_200(t *testing.T) {
var dateValue = "2024-10-02T19:02:46"
type RestorePointTimestamp time.Time
type NormalRestore struct {
TimeStamp time.Time
}
type CustomRestore struct {
TimeStamp RestorePointTimestamp
}
t.Run("normal time", func(t *testing.T) {
normal, _ := time.Parse("2006-01-02T15:04:05", dateValue)
normalRestore := NormalRestore{
TimeStamp: normal,
}
dump.Print(normalRestore)
})
t.Run("custom time", func(t *testing.T) {
custom, _ := time.Parse("2006-01-02T15:04:05", dateValue)
customRestore := CustomRestore{
TimeStamp: RestorePointTimestamp(custom),
}
fmt.Println(isTimeType(customRestore.TimeStamp))
dump.Print(customRestore)
})
}