review_pr self-omitted since 7299b923 deleted the synchronous reviewer it
called. It is rebuilt on the task enqueue path everything else uses: the
tool resolves the identity's configured repo, then queues a pr-review task
naming the pull request through the workflow's declared pr_number input,
which is the same generic input mechanism a watched-repos binding uses.
That input has to reach the store with the task, so
EnqueueChatTaskRequest gains inputs_json and the tasks insert writes the
inputs column directly. StampTaskBinding no longer writes it: the insert is
now the column's only writer, and a chat task must not acquire binding
provenance just to carry an input.
ChatPRReviewer, its result shape and the reviewer wiring are deleted with
the path they served.
49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
package daemon
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore"
|
|
)
|
|
|
|
type workflowDefinitionsStub struct {
|
|
collection workflow.WorkflowDefinitionCollection
|
|
version int64
|
|
}
|
|
|
|
func (s *workflowDefinitionsStub) WorkflowDefinitions(context.Context) (workflow.WorkflowDefinitionCollection, int64, error) {
|
|
return s.collection, s.version, nil
|
|
}
|
|
|
|
func TestWorkflowDefinitionPinSurvivesActiveOverride(t *testing.T) {
|
|
resources := pgstore.Open(t)
|
|
defer resources.Close()
|
|
task, err := resources.EnqueueChatTask(t.Context(), "acme", "widget", "custom", "", "custom", "operator", nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
first := "id: custom\nsteps:\n - type: bootstrap.apply\n"
|
|
provider := &workflowDefinitionsStub{collection: workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{{ID: "custom", YAML: first}}}, version: 4}
|
|
d := &Daemon{Store: resources, WorkflowDefinitions: provider}
|
|
if err := d.pinWorkflowDefinition(t.Context(), task); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
provider.collection.Definitions[0].YAML = "id: custom\nsteps:\n - type: bootstrap.prepare\n"
|
|
provider.version = 5
|
|
if err := d.pinWorkflowDefinition(t.Context(), task); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if task.WorkflowDefinitionYAML != first || task.WorkflowDefinitionVersion != 4 {
|
|
t.Fatalf("pin changed after override: version=%d yaml=%q", task.WorkflowDefinitionVersion, task.WorkflowDefinitionYAML)
|
|
}
|
|
stored, err := resources.TaskByID(t.Context(), task.ID)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if stored.WorkflowDefinitionDigest != workflow.DigestDefinition(first) {
|
|
t.Fatal("persisted workflow digest does not identify the pinned YAML")
|
|
}
|
|
}
|