tmpFile, err = ioutil.TempFile("", "tmp_json") Expect(err).ToNot(HaveOccurred()) jsonContents = []byte(`{"Value":"test value"}`) Expect(ioutil.WriteFile(tmpFile.Name(), jsonContents, 0700)).To(Succeed()) }) It("submits a task from json", func() { fakeTaskRunner.SubmitTaskReturns("some-task", nil) args := []string{tmpFile.Name()} test_helpers.ExecuteCommandWithArgs(submitTaskCommand, args) Expect(outputBuffer).To(test_helpers.SayLine(colors.Green("Successfully submitted some-task"))) Expect(fakeTaskRunner.SubmitTaskCallCount()).To(Equal(1)) Expect(fakeTaskRunner.SubmitTaskArgsForCall(0)).To(Equal(jsonContents)) }) It("prints an error returned by the task_runner", func() { fakeTaskRunner.SubmitTaskReturns("some-task", errors.New("taskypoo")) args := []string{tmpFile.Name()} test_helpers.ExecuteCommandWithArgs(submitTaskCommand, args) Expect(fakeTaskRunner.SubmitTaskCallCount()).To(Equal(1)) Expect(fakeTaskRunner.SubmitTaskArgsForCall(0)).To(Equal(jsonContents)) Expect(outputBuffer).To(test_helpers.SayLine("Error submitting some-task: taskypoo")) Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.CommandFailed})) })