From 4783429ab7a04941baf0e33edea8a8d76b1152f4 Mon Sep 17 00:00:00 2001 From: Felix Moehler Date: Thu, 4 May 2023 17:43:43 +0200 Subject: [PATCH] add further test --- .../id_device_path_resolver_test.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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")