diff --git a/infrastructure/devicepathresolver/id_device_path_resolver_test.go b/infrastructure/devicepathresolver/id_device_path_resolver_test.go index 82cc96fe8..d3daa3eab 100644 --- a/infrastructure/devicepathresolver/id_device_path_resolver_test.go +++ b/infrastructure/devicepathresolver/id_device_path_resolver_test.go @@ -96,6 +96,38 @@ var _ = Describe("IDDevicePathResolver", func() { }) }) + Context("when disks without a hyphen character exist ", func() { + BeforeEach(func() { + err := fs.MkdirAll("/dev", os.FileMode(0750)) + Expect(err).ToNot(HaveOccurred()) + + err = fs.MkdirAll("/dev/fake-device-path", os.FileMode(0750)) + Expect(err).ToNot(HaveOccurred()) + + err = fs.Symlink("/dev/fake-device-path", "/dev/intermediate/fake-device-path") + Expect(err).ToNot(HaveOccurred()) + + err = fs.Symlink("/dev/intermediate/fake-device-path", "/dev/disk/by-id/virtio-fake_disk_id_include_longname") + Expect(err).ToNot(HaveOccurred()) + + fs.SetGlob("/dev/disk/by-id/*fake_disk_id_include_longname", []string{"/dev/disk/by-id/virtio-fake_disk_id_include_longname"}) + + diskSettings = boshsettings.DiskSettings{ + ID: "fake_disk_id_include_longname", + } + }) + It("returns an error", func() { + path, timeout, err := pathResolver.GetRealDevicePath(diskSettings) + Expect(err).ToNot(HaveOccurred()) + + devicePath, err := filepath.Abs("/dev/fake-device-path") + Expect(err).ToNot(HaveOccurred()) + + Expect(path).To(Equal(devicePath)) + Expect(timeout).To(BeFalse()) + }) + }) + Context("when path does not exist", func() { BeforeEach(func() { err := fs.Symlink("fake-device-path", "/dev/disk/by-id/virtio-fake-disk-id-include-longname")