Files
archie/internal/domain/workflow/baseline_publish_test.go
T
sam 67c9b7a00a fix(workflow): publish a baseline repair as a PR before the task continues (#1844)
Dependents now wait for the baseline gate to pass on the base branch
instead of a specific branch merging.
2026-11-09 14:40:58 +11:00

46 lines
1.3 KiB
Go

package workflow
import (
"context"
"testing"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
)
type prRecorder struct {
Forger
created int
}
func (f *prRecorder) CreatePR(context.Context, string, string, string, string, string, string) (int, error) {
f.created++
return 42, nil
}
// A baseline repair is published as a PR before the task continues, and the
// task's own PR joins it instead of opening a second.
func TestBaselineRepairPRIsReusedByTheTaskPR(t *testing.T) {
forge := &prRecorder{}
trees := &noChangesTrees{}
tc := &TaskContext{
Task: &task.Task{ID: 1, Owner: "acme", Repo: "widgets", Source: task.SourceTest},
Repo: config.Repo{Owner: "acme", Name: "widgets"},
Forge: forge,
Trees: trees,
Branch: "archie/1",
}
if err := publishBaselineRepair(t.Context(), tc, []string{"task", "check"}); err != nil {
t.Fatal(err)
}
if !trees.pushed || tc.BaselinePR != 42 || forge.created != 1 {
t.Fatalf("pushed=%v pr=%d created=%d, want pushed, 42, 1", trees.pushed, tc.BaselinePR, forge.created)
}
if err := OpenPR(t.Context(), tc, "body"); err != nil {
t.Fatal(err)
}
if forge.created != 1 {
t.Fatalf("OpenPR created a second PR (%d)", forge.created)
}
}