MCPcopy
hub / github.com/nektos/act / TestNewParallelExecutor

Function TestNewParallelExecutor

pkg/common/executor_test.go:77–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestNewParallelExecutor(t *testing.T) {
78 assert := assert.New(t)
79
80 ctx := context.Background()
81
82 count := 0
83 activeCount := 0
84 maxCount := 0
85 emptyWorkflow := NewPipelineExecutor(func(_ context.Context) error {
86 count++
87
88 activeCount++
89 if activeCount > maxCount {
90 maxCount = activeCount
91 }
92 time.Sleep(2 * time.Second)
93 activeCount--
94
95 return nil
96 })
97
98 err := NewParallelExecutor(2, emptyWorkflow, emptyWorkflow, emptyWorkflow)(ctx)
99
100 assert.Equal(3, count, "should run all 3 executors")
101 assert.Equal(2, maxCount, "should run at most 2 executors in parallel")
102 assert.Nil(err)
103
104 // Reset to test running the executor with 0 parallelism
105 count = 0
106 activeCount = 0
107 maxCount = 0
108
109 errSingle := NewParallelExecutor(0, emptyWorkflow, emptyWorkflow, emptyWorkflow)(ctx)
110
111 assert.Equal(3, count, "should run all 3 executors")
112 assert.Equal(1, maxCount, "should run at most 1 executors in parallel")
113 assert.Nil(errSingle)
114}
115
116func TestNewParallelExecutorFailed(t *testing.T) {
117 assert := assert.New(t)

Callers

nothing calls this directly

Calls 2

NewPipelineExecutorFunction · 0.85
NewParallelExecutorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…