package workflow import ( "context" "log/slog" "testing" "github.com/samcharles93/archie-core/internal/domain/workflow/task" ) // Intake allocates tc.prReview on every entry, so the own-PR flag is recorded // after the decision stages, on the state they built. Recording it before them // dereferenced a nil state and panicked the agent container at the end of every // implement run, before the pull request was opened. func TestOwnPRReviewRecordsOwnPRAfterTheDecisionStages(t *testing.T) { tc := &TaskContext{Task: &task.Task{ID: 7, Source: task.SourceTest, Owner: "o", Repo: "r"}, Log: slog.Default()} RecordDeliveries(tc) intake := Stage{Name: "intake", Run: func(_ context.Context, tc *TaskContext) error { tc.prReview = &prReviewState{} return nil }} stage := stagePRReviewAndOpenPR([]Stage{intake}, func(*TaskContext) string { return "" }) if err := stage.Run(context.Background(), tc); err != nil { t.Fatalf("own-PR review: %v", err) } if !tc.prReview.ownPR { t.Fatal("the pull request this run opened is not marked as its own") } }