package devices import ( "io/fs" "path/filepath" ) var ( testDevice Device testRootDevPath = "testdata/dev" testRootSysPath = "testdata/sys" testDevicePath = filepath.Join(testRootSysPath, "devices", "usb") mockSubsystemFn = func(path string) (string, error) { return filepath.Dir(path), nil } mockDeviceTypeFn = func(_ string) (string, error) { return "char", nil } ) func SetTestEnvs() { // set test paths DevPath = testRootDevPath SysPath = testRootSysPath sysDevicePath = filepath.Join(testRootSysPath, "devices") sysBusPath = filepath.Join(testRootSysPath, "bus") sysClassPath = filepath.Join(testRootSysPath, "class") subSystemSymlinkFn = mockSubsystemFn deviceTypeFn = mockDeviceTypeFn isSymlinkFn = func(fileInfo fs.FileInfo) bool { return fileInfo.Mode()&fs.ModeSymlink != 0 } }