Finish native completion and retire legacy command machinery
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -23,23 +23,17 @@ func TestPlanDoesNotCreateWorkdir(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot)
|
||||
|
||||
var out bytes.Buffer
|
||||
args := []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}
|
||||
args := []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session-file", sessionPath}
|
||||
|
||||
if err := Plan(context.Background(), args, &out); err != nil {
|
||||
if err := invokeNativeCommand(context.Background(), append([]string{"session", "plan"}, args...), &out); err != nil {
|
||||
t.Fatalf("first Plan() error = %v", err)
|
||||
}
|
||||
got := out.String()
|
||||
if !strings.Contains(got, "narratio session plan: read-only workdir at") {
|
||||
t.Fatalf("first output = %q, want read-only workdir", got)
|
||||
}
|
||||
for _, name := range []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "render", "extract", "analyze", "publish", "notify", "cleanup"} {
|
||||
if !strings.Contains(got, name+": run") {
|
||||
t.Fatalf("first output = %q, missing stage %q", got, name)
|
||||
report := decodeNativeReport[sessionPlanReport](t, out.Bytes())
|
||||
for index, name := range canonicalStageNames() {
|
||||
if index >= len(report.Stages) || report.Stages[index].Name != name || report.Stages[index].Action != "run" {
|
||||
t.Fatalf("initial plan=%#v", report)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(got, "totals: run=12 skip=0") {
|
||||
t.Fatalf("first output = %q, want totals", got)
|
||||
}
|
||||
|
||||
sessionWorkdir := artifacts.SessionWorkDirForCampaign(workspaceRoot, "sample-campaign", "2026-05-03")
|
||||
if _, err := os.Stat(sessionWorkdir); !errors.Is(err, os.ErrNotExist) {
|
||||
@@ -47,12 +41,13 @@ func TestPlanDoesNotCreateWorkdir(t *testing.T) {
|
||||
}
|
||||
|
||||
out.Reset()
|
||||
if err := Plan(context.Background(), args, &out); err != nil {
|
||||
if err := invokeNativeCommand(context.Background(), append([]string{"session", "plan"}, args...), &out); err != nil {
|
||||
t.Fatalf("second Plan() error = %v", err)
|
||||
}
|
||||
if !strings.Contains(out.String(), "narratio session plan: read-only workdir at") {
|
||||
t.Fatalf("second output = %q, want read-only workdir", out.String())
|
||||
if repeated := decodeNativeReport[sessionPlanReport](t, out.Bytes()); !reflect.DeepEqual(repeated, report) {
|
||||
t.Fatalf("read-only plan changed: %#v", repeated)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestPlanShowsRunAndSkipFromManifest(t *testing.T) {
|
||||
@@ -73,19 +68,23 @@ func TestPlanShowsRunAndSkipFromManifest(t *testing.T) {
|
||||
}
|
||||
|
||||
var out bytes.Buffer
|
||||
if err := Plan(context.Background(), []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &out); err != nil {
|
||||
if err := invokeNativeCommand(context.Background(), []string{"session", "plan", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session-file", sessionPath}, &out); err != nil {
|
||||
t.Fatalf("Plan() error = %v", err)
|
||||
}
|
||||
got := out.String()
|
||||
if !strings.Contains(got, "prepare: skip") || !strings.Contains(got, "transcribe: skip") {
|
||||
t.Fatalf("output = %q, want prepare/transcribe skipped", got)
|
||||
report := decodeNativeReport[sessionPlanReport](t, out.Bytes())
|
||||
skipped := 0
|
||||
for _, item := range report.Stages {
|
||||
if item.Action == "skip" {
|
||||
skipped++
|
||||
if item.Name != "prepare" && item.Name != "transcribe" {
|
||||
t.Fatalf("unexpected reuse: %#v", item)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !strings.Contains(got, "trim: run") {
|
||||
t.Fatalf("output = %q, want trim run", got)
|
||||
}
|
||||
if !strings.Contains(got, "totals: run=10 skip=2") {
|
||||
t.Fatalf("output = %q, want totals run=10 skip=2", got)
|
||||
if skipped != 2 || len(report.Stages) != len(canonicalStageNames()) {
|
||||
t.Fatalf("plan=%#v", report)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestPlanSkipsAbsentConventionalSecretsDirectory(t *testing.T) {
|
||||
@@ -124,7 +123,7 @@ inputs:
|
||||
}
|
||||
|
||||
var out bytes.Buffer
|
||||
err := Plan(context.Background(), []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &out)
|
||||
err := invokeNativeCommand(context.Background(), []string{"session", "plan", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session-file", sessionPath}, &out)
|
||||
if err != nil {
|
||||
t.Fatalf("Plan() error = %v, want absent conventional secrets directory skipped", err)
|
||||
}
|
||||
@@ -179,24 +178,31 @@ func TestPlanAndRunShareAnalyzeArtifactDecisionsWithoutPlanSideEffects(t *testin
|
||||
t.Setenv("PATH", binaryDir+string(os.PathListSeparator)+os.Getenv("PATH"))
|
||||
|
||||
var out bytes.Buffer
|
||||
err = Plan(context.Background(), []string{
|
||||
"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath,
|
||||
err = invokeNativeCommand(context.Background(), []string{"session", "plan", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session-file", sessionPath,
|
||||
"--from", "render", "--through", "analyze",
|
||||
}, &out)
|
||||
if err != nil {
|
||||
t.Fatalf("Plan() error = %v", err)
|
||||
}
|
||||
got := out.String()
|
||||
for _, want := range []string{
|
||||
"render: run", "extract: run", "analyze: run",
|
||||
" targets: player_handout, session_recap",
|
||||
" prerequisites: none", " execute: none",
|
||||
"player_handout(target:current)", "session_recap(target:current)",
|
||||
} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Fatalf("plan output = %q, want %q", got, want)
|
||||
report := decodeNativeReport[sessionPlanReport](t, out.Bytes())
|
||||
if len(report.Stages) != 3 {
|
||||
t.Fatalf("bounded plan=%#v", report)
|
||||
}
|
||||
for _, item := range report.Stages {
|
||||
if item.Action != "run" {
|
||||
t.Fatalf("stage plan=%#v", item)
|
||||
}
|
||||
}
|
||||
analysis := report.Stages[2].Analysis
|
||||
if analysis == nil || len(analysis.Execute) != 0 || len(analysis.Prerequisites) != 0 || len(analysis.Reuse) != 2 {
|
||||
t.Fatalf("analysis plan=%#v", analysis)
|
||||
}
|
||||
for _, item := range analysis.Reuse {
|
||||
if item.Role != "target" || item.Reason != "current" {
|
||||
t.Fatalf("artifact reuse=%#v", item)
|
||||
}
|
||||
}
|
||||
|
||||
manifestAfter, err := os.ReadFile(first.ManifestPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user