summaryrefslogtreecommitdiff
path: root/toolbox/toolbox_test.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2026-01-01 18:12:44 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2026-01-01 18:24:02 +0100
commit9e5c5ada9907247cbeeadf2e9b817a015abf888f (patch)
tree65111d833a28abe545f392f70e1026916581f7d9 /toolbox/toolbox_test.go
parentinitial commit (diff)
downloadodescsitoolbox-6163643b019fbaf422cdce04f2d1ed0fa2855b23.tar.xz
feat: SCSI Toolbox for Linuxv0.1.0
Support the SCSI Toolbox API on Linux using "SCSI Generic" driver and the "SG_IO" ioctl, along with an extremely simple CLI tool to interact with the SCSI emulator.
Diffstat (limited to 'toolbox/toolbox_test.go')
-rw-r--r--toolbox/toolbox_test.go62
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)
+ })
+ }
+}