-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
p2p_test.go
66 lines (61 loc) · 1.17 KB
/
p2p_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package ptr
import (
"reflect"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestPointerInt64ToTime(t *testing.T) {
as := assert.New(t)
tests := []struct {
name string
args *int64
want []string
}{
{
name: "to-time-1617879700",
args: nil,
want: []string{},
},
{
name: "to-time-1617879700",
args: Int64(1617879700),
want: []string{"2021-04-08T19:01:40", "2021-04-08T11:01:40"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := PointerInt64ToTime(tt.args)
if len(tt.want) == 0 {
as.Nil(got)
} else {
as.Contains(tt.want, got.Format("2006-01-02T15:04:05"))
}
})
}
}
func TestPointerTimeToInt64(t *testing.T) {
tests := []struct {
name string
args *time.Time
want *int64
}{
{
name: "nil time to nil int64",
args: nil,
want: nil,
},
{
name: "pointer time to pointer int64",
args: Time(time.Unix(24580, 0)),
want: Int64(24580),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := PointerTimeToInt64(tt.args); !reflect.DeepEqual(got, tt.want) {
t.Errorf("PointerTimeToInt64() = %v, want %v", got, tt.want)
}
})
}
}