//nolint:typecheck package devices import ( "testing" . "github.com/onsi/ginkgo/v2" //nolint:revive . "github.com/onsi/gomega" //nolint:revive ) // Mock dev path and subsystem logic without symlink support // 1. change the root dev path to testing path. // 2. change the subsystem function to return current base path since symlinks do not work. // 3. change the isRegular function since the embedded files are symlinks. var _ = BeforeSuite(func() { SetTestEnvs() var err error testDevice, err = New(testDevicePath) Expect(err).To(BeNil()) }) // Ensure file system mocks are reset var _ = BeforeEach(func() { SetTestEnvs() }) func TestDeviceRead(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Device Tests") } var _ = Describe("Read device from sys fs", func() { It("Read basic usb device", func() { device, err := New(testDevicePath) Expect(err).To(BeNil()) Expect(device).NotTo(BeNil()) Expect(device.Path()).To(Equal(testDevicePath)) subsystem, found, err := device.Property("SUBSYSTEM") Expect(err).To(BeNil()) Expect(found).To(BeTrue()) Expect(subsystem).To(Equal("usb")) }) })