diff options
Diffstat (limited to 'toolbox/toolbox_test.go')
| -rw-r--r-- | toolbox/toolbox_test.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/toolbox/toolbox_test.go b/toolbox/toolbox_test.go new file mode 100644 index 0000000..7548be3 --- /dev/null +++ b/toolbox/toolbox_test.go @@ -0,0 +1,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) + }) + } +} |
