Пример #1
0
	It("is not persistent", func() {
		Expect(runScriptAction.IsPersistent()).To(BeFalse())
	})

	Context("when script exists", func() {

		var existingScript *fakescript.FakeScript

		BeforeEach(func() {
			existingScript = &fakescript.FakeScript{}
			existingScript.ExistsReturns(true)
			fakeJobScriptProvider.GetReturns(existingScript)
		})

		It("is executed", func() {
			existingScript.RunReturns(scriptrunner.RunScriptResult{Tag: "fake-job-1", ScriptPath: "path/to/script1", Error: nil})
			results, err := runScriptAction.Run(scriptName, options)

			Expect(err).ToNot(HaveOccurred())
			Expect(results).To(Equal(map[string]string{"fake-job-1": "executed"}))
		})

		It("gives an error when script fails", func() {
			existingScript.RunReturns(scriptrunner.RunScriptResult{Tag: "fake-job-1", ScriptPath: "path/to/script1", Error: errors.New("fake-error")})

			results, err := runScriptAction.Run(scriptName, options)

			Expect(err).To(HaveOccurred())
			Expect(results).To(Equal(map[string]string{"fake-job-1": "failed"}))
		})
Пример #2
0
		BeforeEach(func() {
			existingScript = &fakescript.FakeScript{}
			existingScript.ExistsReturns(true)
			fakeScriptProvider.GetReturns(existingScript)
		})

		It("is executed", func() {
			preStart, err := runScriptAction.Run(scriptPaths, options)

			Expect(err).ToNot(HaveOccurred())
			Expect(preStart).To(Equal("executed"))
		})

		It("gives an error when script fails", func() {
			existingScript.RunReturns("stdout from before the error", "stderr from before the error", errors.New("fake-generic-run-script-error"))
			preStart, err := runScriptAction.Run(scriptPaths, options)

			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("fake-generic-run-script-error"))
			Expect(preStart).To(Equal("failed"))
		})
	})

	Context("when script does not exist", func() {

		var nonExistingScript *fakescript.FakeScript

		BeforeEach(func() {
			nonExistingScript = &fakescript.FakeScript{}
			nonExistingScript.ExistsReturns(false)