mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-21 00:30:12 -06:00
* re-add new testing harness * add healthcheck port and pick random grpc port to listen on * feat: parallel load tests and faster tests * make parallelism = 5 * fix: lint * add linter to pre * fix: add back rampup fixes * reduce matrix on PR, add matrix to pre-release step * make load tests less likely to block * make limit strategy group round robin * uncomment lines
65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
//go:build !e2e && !load && !rampup && !integration
|
|
|
|
package dagutils_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hatchet-dev/hatchet/internal/dagutils"
|
|
"github.com/hatchet-dev/hatchet/pkg/repository"
|
|
)
|
|
|
|
func TestHasCycle(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
steps []repository.CreateWorkflowStepOpts
|
|
expected bool
|
|
}{
|
|
{
|
|
name: "No cycle",
|
|
steps: []repository.CreateWorkflowStepOpts{
|
|
{ReadableId: "Step1", Action: "Action1", Parents: []string{"Step2"}},
|
|
{ReadableId: "Step2", Action: "Action2"},
|
|
},
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "Self referential cycle",
|
|
steps: []repository.CreateWorkflowStepOpts{
|
|
{ReadableId: "Step1", Action: "Action1", Parents: []string{"Step1"}},
|
|
},
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "Simple cycle",
|
|
steps: []repository.CreateWorkflowStepOpts{
|
|
{ReadableId: "Step1", Action: "Action1", Parents: []string{"Step2"}},
|
|
{ReadableId: "Step2", Action: "Action2", Parents: []string{"Step1"}},
|
|
},
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "Complex cycle",
|
|
steps: []repository.CreateWorkflowStepOpts{
|
|
{ReadableId: "Step1", Action: "Action1", Parents: []string{"Step3"}},
|
|
{ReadableId: "Step2", Action: "Action2", Parents: []string{"Step1"}},
|
|
{ReadableId: "Step3", Action: "Action3", Parents: []string{"Step2"}},
|
|
},
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "No Steps",
|
|
steps: []repository.CreateWorkflowStepOpts{},
|
|
expected: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := dagutils.HasCycle(tt.steps); got != tt.expected {
|
|
t.Errorf("HasCycle() = %v, expected %v", got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|