コード例 #1
0
ファイル: run_script_test.go プロジェクト: gu-bin/bosh-agent
		runScriptAction = action.NewRunScript(fakeJobScriptProvider, specService, log)
		scriptName = "run-me"
		options = make(map[string]interface{})
	})

	It("is asynchronous", func() {
		Expect(runScriptAction.IsAsynchronous()).To(BeTrue())
	})

	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"}))
		})
コード例 #2
0
ファイル: run_script_test.go プロジェクト: guoger/bosh-agent
		runScriptAction = action.NewRunScript(fakeScriptProvider, log)
		scriptPaths = []string{"run-me"}
		options = make(map[string]interface{})
	})

	It("is synchronous", func() {
		Expect(runScriptAction.IsAsynchronous()).To(BeTrue())
	})

	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)
			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() {