forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo_test.go
More file actions
44 lines (42 loc) · 760 Bytes
/
info_test.go
File metadata and controls
44 lines (42 loc) · 760 Bytes
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
package slack
import (
"testing"
)
func TestJSONTime_UnmarshalJSON(t *testing.T) {
type args struct {
buf []byte
}
tests := []struct {
name string
args args
wantTr JSONTime
wantErr bool
}{
{
"acceptable int64 timestamp",
args{[]byte(`1643435556`)},
JSONTime(1643435556),
false,
},
{
"acceptable string timestamp",
args{[]byte(`"1643435556"`)},
JSONTime(1643435556),
false,
},
{
"null",
args{[]byte(`null`)},
JSONTime(0),
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var tr JSONTime
if err := tr.UnmarshalJSON(tt.args.buf); (err != nil) != tt.wantErr {
t.Errorf("JSONTime.UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}