var ( context *fakes.Context command1 *fakes.Command command2 *fakes.Command command3 *fakes.Command all executor.Command ) BeforeEach(func() { context = &fakes.Context{} command1 = &fakes.Command{} command2 = &fakes.Command{} command3 = &fakes.Command{} command1.StringReturns("some-command 1") command2.StringReturns("some-command 2") command3.StringReturns("some-command 3") all = commands.All(command1, command2, command3) }) Describe("Execute", func() { It("creates a command wrapper that executes all commands", func() { err := all.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(command1.ExecuteCallCount()).To(Equal(1)) Expect(command1.ExecuteArgsForCall(0)).To(Equal(context)) Expect(command2.ExecuteCallCount()).To(Equal(1))
. "github.com/onsi/gomega" ) var _ = Describe("ExecuteInNamespace", func() { var ( context *fakes.Context namespace *fakes.Namespace command *fakes.Command inNamespace commands.InNamespace ) BeforeEach(func() { context = &fakes.Context{} command = &fakes.Command{} command.StringReturns("some-command") namespace = &fakes.Namespace{} namespace.NameReturns("namespace-name") namespace.ExecuteStub = func(callback func(*os.File) error) error { Expect(command.ExecuteCallCount()).To(Equal(0)) err := callback(nil) Expect(command.ExecuteCallCount()).To(Equal(1)) return err } inNamespace = commands.InNamespace{ Namespace: namespace,
var _ = Describe("unless", func() { var ( context *fakes.Context condition *fakes.Condition command *fakes.Command unless commands.Unless ) BeforeEach(func() { context = &fakes.Context{} condition = &fakes.Condition{} condition.StringReturns("condition") command = &fakes.Command{} command.StringReturns("command") unless = commands.Unless{ Condition: condition, Command: command, } }) Describe("String", func() { It("returns a string representation of the command", func() { Expect(unless.String()).To(Equal("condition || command")) }) }) Context("when the condition is satisfied", func() { BeforeEach(func() {