Exemple #1
0
func (s *mockRemoteOps) UploadFile(lfile io.Reader) error {

	if s.Writer == nil {
		s.Writer = mock.NewReadWriteCloser(nil, nil, nil)
	}

	if s.Err == nil {
		_, s.Err = io.Copy(s.Writer, lfile)
	}
	return s.Err
}
Exemple #2
0
			})

			It("should write the local file contents to the remote", func() {
				Ω(buffer).Should(gbytes.Say(controlString))
			})
		})

		Context("error on file upload", func() {
			BeforeEach(func() {
				buffer = gbytes.NewBuffer()
				nfs = getNfs(buffer, &SuccessMockNFSExecuter{})
			})

			Context("Read failure", func() {
				BeforeEach(func() {
					lf := mock.NewReadWriteCloser(mock.ErrReadFailure, nil, nil)
					err = nfs.Import(lf)
				})

				It("should return non-nil execution error", func() {
					Ω(err).ShouldNot(BeNil())
					Ω(err).Should(Equal(mock.ErrReadFailure))
				})

				It("should write the local file contents to the remote", func() {
					Ω(buffer).ShouldNot(gbytes.Say(controlString))
				})
			})

			Context("Writer related failure", func() {
				Context("Write failure", func() {
Exemple #3
0
				Ω(err).ShouldNot(BeNil())
				Ω(err).Should(Equal(sftpFailErr))
				Ω(output.String()).ShouldNot(Equal(string(larray[:])))
			})
		})

		Context("called w/ failed copy to remote", func() {
			BeforeEach(func() {
				pgDumpInstance.RemoteOps = &mockRemoteOps{
					Err: mock.READ_FAIL_ERROR,
				}
			})

			It("should return failed copy error", func() {
				l := mock.NewReadWriteCloser(mock.READ_FAIL_ERROR, nil, nil)
				err := pgDumpInstance.Import(l)
				Ω(err).ShouldNot(BeNil())
				Ω(err).Should(Equal(mock.READ_FAIL_ERROR))
			})
		})

		Context("remote call w/ failed result from first call", func() {
			BeforeEach(func() {
				pgDumpInstance.Caller = &MockFailCall{}
				pgDumpInstance.RemoteOps = &mockRemoteOps{}
			})

			It("should return a call error", func() {
				l := mock.NewReadWriteCloser(nil, nil, nil)
				err := pgDumpInstance.Import(l)
Exemple #4
0
			})

			It("should write the local file contents to the remote", func() {
				Ω(buffer).Should(gbytes.Say(controlString))
			})
		})

		Context("error on file upload", func() {
			BeforeEach(func() {
				buffer = gbytes.NewBuffer()
				nfs = getNfs(buffer, &SuccessMockNFSExecuter{})
			})

			Context("Read failure", func() {
				BeforeEach(func() {
					lf := mock.NewReadWriteCloser(mock.READ_FAIL_ERROR, nil, nil)
					err = nfs.Import(lf)
				})

				It("should return non-nil execution error", func() {
					Ω(err).ShouldNot(BeNil())
					Ω(err).Should(Equal(mock.READ_FAIL_ERROR))
				})

				It("should write the local file contents to the remote", func() {
					Ω(buffer).ShouldNot(gbytes.Say(controlString))
				})
			})

			Context("Writer related failure", func() {
				Context("Write failure", func() {