StagePRReviewAndOpenPR set tc.prReview.ownPR before the decision stages ran, but intake allocates tc.prReview, so every implement run dereferenced a nil state at repo.open-pr and the agent container panicked with exit code 2 before opening the pull request.
31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
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")
|
|
}
|
|
}
|