Ejemplo n.º 1
0
package cdrom_test

import (
	"errors"

	. "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-agent/platform/cdrom"
	fakeudev "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-agent/platform/udevdevice/fakes"
	fakesys "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/system/fakes"
	. "github.com/cloudfoundry/bosh-init/internal/github.com/onsi/ginkgo"
	. "github.com/cloudfoundry/bosh-init/internal/github.com/onsi/gomega"
)

var _ = Describe("LinuxCdrom", func() {
	var (
		udev   *fakeudev.FakeUdevDevice
		runner *fakesys.FakeCmdRunner
		cd     Cdrom
	)

	BeforeEach(func() {
		udev = fakeudev.NewFakeUdevDevice()
		runner = fakesys.NewFakeCmdRunner()
	})

	JustBeforeEach(func() {
		cd = NewLinuxCdrom("/dev/sr0", udev, runner)
	})

	Describe("WaitForMedia", func() {
		It("polls the cdrom to force udev to notice it", func() {
			err := cd.WaitForMedia()
	"time"

	fakeudev "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-agent/platform/udevdevice/fakes"
	boshsettings "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-agent/settings"
	fakesys "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/system/fakes"

	. "github.com/cloudfoundry/bosh-init/internal/github.com/onsi/ginkgo"
	. "github.com/cloudfoundry/bosh-init/internal/github.com/onsi/gomega"

	. "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-agent/infrastructure/devicepathresolver"
)

var _ = Describe("IDDevicePathResolver", func() {
	var (
		fs           *fakesys.FakeFileSystem
		udev         *fakeudev.FakeUdevDevice
		diskSettings boshsettings.DiskSettings
		pathResolver DevicePathResolver
	)

	BeforeEach(func() {
		udev = fakeudev.NewFakeUdevDevice()
		fs = fakesys.NewFakeFileSystem()
		pathResolver = NewIDDevicePathResolver(500*time.Millisecond, udev, fs)
		diskSettings = boshsettings.DiskSettings{
			ID: "fake-disk-id-include-truncate",
		}
	})

	Describe("GetRealDevicePath", func() {
		It("refreshes udev", func() {
			pathResolver.GetRealDevicePath(diskSettings)