Skip to content

Commit

Permalink
add further test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoehler committed May 4, 2023
1 parent 3e567c8 commit 4783429
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions infrastructure/devicepathresolver/id_device_path_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 4783429

Please sign in to comment.