Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Sep 18, 2024
1 parent 32ab35a commit 2d703e7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
8 changes: 6 additions & 2 deletions examples/cancellation/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ func run(events chan<- string) (func() error, error) {

for _, stepRun := range stepRuns {
stepRunID := stepRun.ID
log.Printf("cancelling step run id: %s", stepRunID)
res, err := c.API().StepRunUpdateCancelWithResponse(context.Background(), uuid.MustParse(c.TenantId()), uuid.MustParse(stepRunID))
log.Printf("cancelling step run id: %d", stepRunID)
res, err := c.API().StepRunUpdateCancelWithResponse(
context.Background(),
uuid.MustParse(c.TenantId()),
fmt.Sprint(stepRunID),
)
if err != nil {
panic(fmt.Errorf("error cancelling step run: %w", err))
}
Expand Down
14 changes: 10 additions & 4 deletions examples/timeout/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,26 @@ func run(done chan<- string, job worker.WorkflowJob) (func() error, error) {
).With(
db.Event.WorkflowRuns.Fetch().With(
db.WorkflowRunTriggeredBy.Parent.Fetch().With(
db.WorkflowRun.JobRuns.Fetch().With(
db.JobRun.StepRuns.Fetch(),
),
db.WorkflowRun.JobRuns.Fetch(),
),
),
).Exec(context.Background())

if err != nil {
panic(fmt.Errorf("error finding events: %w", err))
}

for _, event := range events {
for _, workflowRun := range event.WorkflowRuns() {
for _, jobRuns := range workflowRun.Parent().JobRuns() {
for _, stepRun := range jobRuns.StepRuns() {
stepRuns, err := client.StepRun.FindMany(
db.StepRun.JobRunID.Equals(jobRuns.ID),
).Exec(context.Background())
if err != nil {
panic(fmt.Errorf("error finding step runs: %w", err))
}

for _, stepRun := range stepRuns {
if stepRun.Status != db.StepRunStatusFailed {
panic(fmt.Errorf("expected step run to be failed, got %s", stepRun.Status))
}
Expand Down
14 changes: 10 additions & 4 deletions examples/webhook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ func verifyStepRuns(prisma *db.PrismaClient, event string, tenantId string, jobR
).With(
db.Event.WorkflowRuns.Fetch().With(
db.WorkflowRunTriggeredBy.Parent.Fetch().With(
db.WorkflowRun.JobRuns.Fetch().With(
db.JobRun.StepRuns.Fetch(),
),
db.WorkflowRun.JobRuns.Fetch(),
),
),
).Exec(context.Background())
Expand All @@ -120,7 +118,15 @@ func verifyStepRuns(prisma *db.PrismaClient, event string, tenantId string, jobR
if jobRuns.Status != jobRunStatus {
panic(fmt.Errorf("expected job run to be %s, got %s", jobRunStatus, jobRuns.Status))
}
for _, stepRun := range jobRuns.StepRuns() {

stepRuns, err := prisma.StepRun.FindMany(
db.StepRun.JobRunID.Equals(jobRuns.ID),
).Exec(context.Background())
if err != nil {
panic(fmt.Errorf("error finding step runs: %w", err))
}

for _, stepRun := range stepRuns {
if stepRun.Status != stepRunStatus {
panic(fmt.Errorf("expected step run to be %s, got %s", stepRunStatus, stepRun.Status))
}
Expand Down

0 comments on commit 2d703e7

Please sign in to comment.