-
Notifications
You must be signed in to change notification settings - Fork 1
/
item_test.go
73 lines (69 loc) · 1.41 KB
/
item_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
67
68
69
70
71
72
73
package qiisync
import (
"reflect"
"testing"
"time"
)
func TestMarshalTag(t *testing.T) {
type args struct {
tagString string
}
tests := []struct {
name string
args args
want []*Tag
}{
{
name: "normal",
args: args{
tagString: "Go:1.12:1.13:1.14,Python:3.7:3.8",
},
want: []*Tag{
{Name: "Go", Versions: []string{"1.12", "1.13", "1.14"}},
{Name: "Python", Versions: []string{"3.7", "3.8"}},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := MarshalTag(tt.args.tagString); !reflect.DeepEqual(got, tt.want) {
t.Errorf("MarshalTag() = %v, want %v", got, tt.want)
}
})
}
}
func TestUnmarshalTag(t *testing.T) {
type args struct {
Tags []*Tag
}
tests := []struct {
name string
args args
want string
}{
{
name: "normal",
args: args{
Tags: []*Tag{
{Name: "Go", Versions: []string{"1.12", "1.13", "1.14"}},
{Name: "Python", Versions: []string{"3.7", "3.8"}},
},
},
want: "Go:1.12:1.13:1.14,Python:3.7:3.8",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := unmarshalTag(tt.args.Tags); got != tt.want {
t.Errorf("unmarshalTag() = %v, want %v", got, tt.want)
}
})
}
}
func TestDateFormat(t *testing.T) {
got := time.Date(2020, 4, 22, 20, 43, 00, 0, time.UTC)
want := "20200422"
if dateFormat(got) != want {
t.Errorf("dateFormat() = %v, want %v", got, want)
}
}