當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeMounter.MountErr方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter.MountErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeMounter.MountErr方法的具體用法?Golang FakeMounter.MountErr怎麽用?Golang FakeMounter.MountErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter的用法示例。


在下文中一共展示了FakeMounter.MountErr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

var _ = Describe("linuxBindMounter", func() {
	var (
		delegateErr     error
		delegateMounter *fakedisk.FakeMounter
		mounter         Mounter
	)

	BeforeEach(func() {
		delegateErr = errors.New("fake-err")
		delegateMounter = &fakedisk.FakeMounter{}
		mounter = NewLinuxBindMounter(delegateMounter)
	})

	Describe("Mount", func() {
		It("delegates to mounter and adds --bind option to mount as a bind-mount", func() {
			delegateMounter.MountErr = delegateErr

			err := mounter.Mount("fake-partition-path", "fake-mount-path", "fake-opt1")

			// Outputs
			Expect(err).To(Equal(delegateErr))

			// Inputs
			Expect(delegateMounter.MountPartitionPaths).To(Equal([]string{"fake-partition-path"}))
			Expect(delegateMounter.MountMountPoints).To(Equal([]string{"fake-mount-path"}))
			Expect(delegateMounter.MountMountOptions).To(Equal([][]string{{"fake-opt1", "--bind"}}))
		})
	})

	Describe("RemountAsReadonly", func() {
		It("does not delegate to mounter because remount with --bind does not work", func() {
開發者ID:mattcui,項目名稱:bosh-agent,代碼行數:31,代碼來源:linux_bind_mounter_test.go

示例2: describeLinuxPlatform


//.........這裏部分代碼省略.........
				Expect(sysStats.SymlinkTarget).To(Equal("/fake-dir/data/sys"))
			})

			It("creates new sys/run dir", func() {
				err := platform.SetupDataDir()
				Expect(err).NotTo(HaveOccurred())

				sysRunStats := fs.GetFileTestStat("/fake-dir/data/sys/run")
				Expect(sysRunStats).ToNot(BeNil())
				Expect(sysRunStats.FileType).To(Equal(fakesys.FakeFileTypeDir))
				Expect(sysRunStats.FileMode).To(Equal(os.FileMode(0750)))
				Expect(cmdRunner.RunCommands[2]).To(Equal([]string{"chown", "root:vcap", "/fake-dir/data/sys/run"}))
			})

			It("mounts tmpfs to sys/run", func() {
				err := platform.SetupDataDir()
				Expect(err).NotTo(HaveOccurred())

				Expect(len(mounter.MountPartitionPaths)).To(Equal(1))
				Expect(mounter.MountPartitionPaths[0]).To(Equal("tmpfs"))
				Expect(mounter.MountMountPoints[0]).To(Equal("/fake-dir/data/sys/run"))
				Expect(mounter.MountMountOptions[0]).To(Equal([]string{"-t", "tmpfs", "-o", "size=1m"}))
			})

			It("returns an error if creation of mount point fails", func() {
				fs.MkdirAllError = errors.New("fake-mkdir-error")

				err := platform.SetupDataDir()
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-mkdir-error"))
			})

			It("returns an error if mounting tmpfs fails", func() {
				mounter.MountErr = errors.New("fake-mount-error")

				err := platform.SetupDataDir()
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-mount-error"))
			})
		})
	})

	Describe("SetupTmpDir", func() {
		act := func() error { return platform.SetupTmpDir() }

		var mounter *fakedisk.FakeMounter
		BeforeEach(func() {
			mounter = diskManager.FakeMounter
		})

		It("changes permissions on /tmp", func() {
			err := act()
			Expect(err).NotTo(HaveOccurred())

			Expect(cmdRunner.RunCommands[0]).To(Equal([]string{"chown", "root:vcap", "/tmp"}))
			Expect(cmdRunner.RunCommands[1]).To(Equal([]string{"chmod", "0770", "/tmp"}))
			Expect(cmdRunner.RunCommands[2]).To(Equal([]string{"chmod", "0700", "/var/tmp"}))
		})

		It("creates new temp dir", func() {
			err := act()
			Expect(err).NotTo(HaveOccurred())

			fileStats := fs.GetFileTestStat("/fake-dir/data/tmp")
			Expect(fileStats).NotTo(BeNil())
			Expect(fileStats.FileType).To(Equal(fakesys.FakeFileType(fakesys.FakeFileTypeDir)))
開發者ID:guoger,項目名稱:bosh-agent,代碼行數:67,代碼來源:linux_platform_test.go

示例3:

				_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
				Expect(err).ToNot(HaveOccurred())

				Expect(fs.FileExists("fake-tempdir")).To(BeFalse())
			})

			It("returns error if it fails to create temporary mount directory", func() {
				fs.TempDirError = errors.New("fake-tempdir-error")

				_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-tempdir-error"))
			})

			It("returns error if it fails to mount disk path", func() {
				mounter.MountErr = errors.New("fake-mount-error")

				_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-mount-error"))
			})

			It("returns an error if it fails to read the file", func() {
				fs.ReadFileError = errors.New("fake-read-error")
				_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-read-error"))
			})

			It("returns error if it fails to unmount disk path", func() {
				mounter.UnmountErr = errors.New("fake-unmount-error")
開發者ID:viovanov,項目名稱:bosh-agent,代碼行數:31,代碼來源:diskutil_test.go


注:本文中的github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter.MountErr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。