Skip to content

Commit

Permalink
Add test case for failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Oct 6, 2024
1 parent 6ab0dd6 commit 81afcee
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions act/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,8 @@ func Test_Run_Timeout(t *testing.T) {
}
}

// Test_RunAll_And_ShouldTerminate tests the RunAll function of the act registry
// with a terminal action (and signal).
func Test_RunAll_And_ShouldTerminate(t *testing.T) {
out := bytes.Buffer{}
logger := zerolog.New(&out)
Expand Down Expand Up @@ -978,3 +980,37 @@ func Test_RunAll_And_ShouldTerminate(t *testing.T) {
`{"level":"debug","action":"log","executionMode":"async","message":"Running action"}`)
assert.Contains(t, out.String(), `{"level":"info","test":true,"message":"testing log via Act"}`)
}

// Test_RunAll_Empty_Result tests the RunAll function of the act registry with an empty result.
func Test_RunAll_Empty_Result(t *testing.T) {
out := bytes.Buffer{}
logger := zerolog.New(&out)
actRegistry := NewActRegistry(
Registry{
Signals: BuiltinSignals(),
Policies: BuiltinPolicies(),
Actions: BuiltinActions(),
DefaultPolicyName: config.DefaultPolicy,
PolicyTimeout: config.DefaultPolicyTimeout,
DefaultActionTimeout: config.DefaultActionTimeout,
Logger: logger,
})
assert.NotNil(t, actRegistry)

results := []map[string]any{
{},
{
sdkAct.Outputs: false, // This is invalid, hence it will be removed.
},
}

for _, result := range results {
assert.False(t, actRegistry.ShouldTerminate(result))

result = actRegistry.RunAll(result)

time.Sleep(time.Millisecond) // wait for async action to complete

assert.Empty(t, result)
}
}

0 comments on commit 81afcee

Please sign in to comment.