Exemple #1
0
	BeforeEach(func() {
		log = logger.NewLogger(logger.LevelNone)
		fakeJobScriptProvider = &fakescript.FakeJobScriptProvider{}
		specService = fakeapplyspec.NewFakeV1Service()
		createFakeJob("fake-job-1")
		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)