Esempio n. 1
0
		cmdRunner    *fakesys.FakeCmdRunner
		fs           *fakesys.FakeFileSystem
		scriptRunner ScriptRunner
		logger       boshlog.Logger
	)

	BeforeEach(func() {
		scriptCommandFactory := &fakesys.FakeCommandFactory{}
		scriptCommandFactory.ReturnExtension = ".fake-ext"

		cmdRunner = fakesys.NewFakeCmdRunner()

		fs = fakesys.NewFakeFileSystem()

		var err error
		fs.ReturnTempFile, err = fs.OpenFile("/fake-temp-file", os.O_WRONLY, os.ModePerm)
		Expect(err).NotTo(HaveOccurred())

		logger = boshlog.NewLogger(boshlog.LevelNone)
		scriptRunner = NewConcreteScriptRunner(scriptCommandFactory, cmdRunner, fs, logger)
	})

	Describe("RunCommand", func() {
		It("runs a successful script command and doesnt return an error", func() {
			script := `
Write-Output stdout
[Console]::Error.WriteLine('stderr')
`

			cmdRunner.AddCmdResult("/fake-temp-file.fake-ext", fakesys.FakeCmdResult{
				Stdout:     "stdout",