...
1
2 package devices
3
4 import (
5 "testing"
6
7 . "github.com/onsi/ginkgo/v2"
8 . "github.com/onsi/gomega"
9 )
10
11
12
13
14
15 var _ = BeforeSuite(func() {
16 SetTestEnvs()
17 var err error
18 testDevice, err = New(testDevicePath)
19 Expect(err).To(BeNil())
20 })
21
22
23 var _ = BeforeEach(func() {
24 SetTestEnvs()
25 })
26
27 func TestDeviceRead(t *testing.T) {
28 RegisterFailHandler(Fail)
29 RunSpecs(t, "Device Tests")
30 }
31
32 var _ = Describe("Read device from sys fs", func() {
33 It("Read basic usb device", func() {
34 device, err := New(testDevicePath)
35 Expect(err).To(BeNil())
36
37 Expect(device).NotTo(BeNil())
38 Expect(device.Path()).To(Equal(testDevicePath))
39
40 subsystem, found, err := device.Property("SUBSYSTEM")
41 Expect(err).To(BeNil())
42 Expect(found).To(BeTrue())
43 Expect(subsystem).To(Equal("usb"))
44
45 })
46 })
47
View as plain text