From 4dcc1a6b71539ec2d6a77c81da4f330297e5ed96 Mon Sep 17 00:00:00 2001 From: Jahvon Dockery Date: Tue, 24 Dec 2024 16:21:02 -0500 Subject: [PATCH] test: add some tests --- internal/runner/parallel/parallel_test.go | 17 +++++++++++++++++ internal/runner/serial/serial_test.go | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/internal/runner/parallel/parallel_test.go b/internal/runner/parallel/parallel_test.go index fe248b4..c725635 100644 --- a/internal/runner/parallel/parallel_test.go +++ b/internal/runner/parallel/parallel_test.go @@ -130,5 +130,22 @@ var _ = Describe("ParallelRunner", func() { Return(results).Times(1) Expect(parallelRnr.Exec(ctx.Ctx, rootExec, mockEngine, promptedEnv)).ToNot(Succeed()) }) + + It("should skip execution when condition is false", func() { + parallelSpec := rootExec.Parallel + parallelSpec.Execs[0].If = "false" + parallelSpec.Execs[1].If = "true" + mockCache := ctx.ExecutableCache + for i, e := range subExecs { + if i == 1 { + mockCache.EXPECT().GetExecutableByRef(ctx.Logger, e.Ref()).Return(e, nil).Times(1) + } + } + results := engine.ResultSummary{Results: []engine.Result{{}}} + mockEngine.EXPECT(). + Execute(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(results).Times(1) + Expect(parallelRnr.Exec(ctx.Ctx, rootExec, mockEngine, make(map[string]string))).To(Succeed()) + }) }) }) diff --git a/internal/runner/serial/serial_test.go b/internal/runner/serial/serial_test.go index 56ec1ce..bb4d95f 100644 --- a/internal/runner/serial/serial_test.go +++ b/internal/runner/serial/serial_test.go @@ -122,5 +122,21 @@ var _ = Describe("SerialRunner", func() { mockEngine.EXPECT().Execute(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(results).Times(1) Expect(serialRnr.Exec(ctx.Ctx, rootExec, mockEngine, make(map[string]string))).ToNot(Succeed()) }) + + It("should skip execution when condition is false", func() { + serialSpec := rootExec.Serial + serialSpec.Execs[0].If = "false" + serialSpec.Execs[1].If = "true" + mockCache := ctx.ExecutableCache + for i, e := range subExecs { + if i == 1 { + mockCache.EXPECT().GetExecutableByRef(ctx.Logger, e.Ref()).Return(e, nil).Times(1) + } + } + results := engine.ResultSummary{Results: []engine.Result{{}}} + mockEngine.EXPECT().Execute(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). + Return(results).Times(1) + Expect(serialRnr.Exec(ctx.Ctx, rootExec, mockEngine, make(map[string]string))).To(Succeed()) + }) }) })