-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfileinfo_test.go
108 lines (106 loc) · 1.77 KB
/
fileinfo_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package artifact_diff
import (
"reflect"
"testing"
)
func TestArtifactInfo_WithFlattenedAndSortedFileInfos(t *testing.T) {
type fields struct {
Path string
Count int
FileInfos FileInfos
}
fileInfos := FileInfos{}
fileInfos["2"] = &FileInfo{
"zip!/dir/com.example.foo.stuff.jar",
22,
"222",
}
fileInfos["4"] = &FileInfo{
"zip!/dir/com.example.foo.bar_1.2.3.4711.jar",
44,
"444",
}
fileInfos["1"] = &FileInfo{
"zip!/dir/com.example.foo.conf.jar",
11,
"111",
}
fileInfos["3"] = &FileInfo{
"zip!/dir/com.example.foo.jar",
33,
"333",
}
fileInfos["6"] = &FileInfo{
"zip!/dir/com.example.foo-bar.jar",
66,
"666",
}
fileInfos["5"] = &FileInfo{
"zip!/dir/com.example.foo.bar.jar",
55,
"555",
}
expectedFileInfos := []*FileInfo{
{
"zip!/dir/com.example.foo-bar.jar",
66,
"666",
},
{
"zip!/dir/com.example.foo.bar.jar",
55,
"555",
},
{
"zip!/dir/com.example.foo.bar_1.2.3.4711.jar",
44,
"444",
},
{
"zip!/dir/com.example.foo.conf.jar",
11,
"111",
},
{
"zip!/dir/com.example.foo.jar",
33,
"333",
},
{
"zip!/dir/com.example.foo.stuff.jar",
22,
"222",
},
}
tests := []struct {
name string
fields fields
want *FlatArtifactInfo
}{
{
"ensure sorted fileInfos",
fields{
"a/path",
0,
fileInfos,
},
&FlatArtifactInfo{
"a/path",
0,
expectedFileInfos,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
d := &ArtifactInfo{
Path: tt.fields.Path,
Count: tt.fields.Count,
FileInfos: tt.fields.FileInfos,
}
if got := d.WithFlattenedAndSortedFileInfos(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("WithFlattenedAndSortedFileInfos() = %v, want %v", got, tt.want)
}
})
}
}