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
|
// SPDX-FileCopyrightText: 2026 Terin Stock <terinjokes@gmail.com>
// SPDX-License-Identifier: EUPL-1.2
package toolbox
import (
"testing"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
func TestParseFileEntry(t *testing.T) {
type testcase struct {
name string
fileEntry FileEntry
expectedIndex int
expectedName string
expectedType FileType
expectedSize uint64
}
run := func(t *testing.T, tc testcase) {
assert.Equal(t, tc.fileEntry.Index(), tc.expectedIndex)
assert.Equal(t, tc.fileEntry.Name(), tc.expectedName)
assert.Equal(t, tc.fileEntry.FileType(), tc.expectedType)
assert.Equal(t, tc.fileEntry.Size(), tc.expectedSize)
}
testcases := []testcase{
{
name: "normal entry",
fileEntry: FileEntry(golden.Get(t, "fe_normal.golden")),
expectedIndex: 0,
expectedName: "9front-11321.386.iso",
expectedType: File,
expectedSize: 479795200,
},
{
name: "truncated name entry",
fileEntry: FileEntry(golden.Get(t, "fe_truncated.golden")),
expectedIndex: 3,
expectedName: "gentoo-x86-minimal-20251223T1631",
expectedType: File,
expectedSize: 635064320,
},
{
name: "maximium size",
fileEntry: FileEntry(golden.Get(t, "fe_max.golden")),
expectedIndex: 0,
expectedName: "max.iso",
expectedType: File,
expectedSize: 4294967295,
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
run(t, tc)
})
}
}
|