)

var _ = Describe("Path Resolver", func() {
	var (
		fs       boshsys.FileSystem
		resolver DevicePathResolver
	)

	BeforeEach(func() {
		fs = fakesys.NewFakeFileSystem()
		resolver = NewAwsDevicePathResolver(time.Second, fs)
	})

	Context("When a matching /dev/xvdX device is found", func() {
		BeforeEach(func() {
			fs.WriteFile("/dev/xvda", []byte{})
			fs.WriteFile("/dev/vda", []byte{})
			fs.WriteFile("/dev/sda", []byte{})
		})

		It("returns the match", func() {
			realPath, err := resolver.GetRealDevicePath("/dev/sda")
			Expect(err).NotTo(HaveOccurred())
			Expect(realPath).To(Equal("/dev/xvda"))
		})
	})

	Context("When a matching /dev/vdX device is found", func() {
		BeforeEach(func() {
			fs.WriteFile("/dev/vda", []byte{})
			fs.WriteFile("/dev/sda", []byte{})