Skip to content

Commit

Permalink
test: add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jahvon committed Dec 24, 2024
1 parent 1b5a431 commit 4dcc1a6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/runner/parallel/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
})
})
16 changes: 16 additions & 0 deletions internal/runner/serial/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
})
})

0 comments on commit 4dcc1a6

Please sign in to comment.