Run processing from the prepared invocation
This commit is contained in:
@@ -2,6 +2,7 @@ package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -9,6 +10,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/preflight"
|
||||
|
||||
commandkit "go.maximumdirect.net/commandkit"
|
||||
ck "go.maximumdirect.net/configkit"
|
||||
)
|
||||
@@ -106,3 +109,40 @@ func TestCollectionFlagJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInfeasibleChunkingPrecedesOutputInitialization(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
configPath := filepath.Join(dir, "config.yml")
|
||||
transcriptPath := filepath.Join(dir, "transcript.json")
|
||||
outputPath := filepath.Join(dir, "output.json")
|
||||
if err := os.WriteFile(configPath, []byte("version: 3\npipeline:\n stages: []\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(transcriptPath, []byte(`[{"speaker":"Alice","start":0,"end":1,"text":"hello"}]`), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(outputPath, []byte("existing"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
input := processInput{Config: commandkit.Supplied[string]{Value: configPath, Set: true}, Transcript: transcriptPath, Output: commandkit.Supplied[string]{Value: outputPath, Set: true}, Debug: commandkit.Supplied[bool]{Value: true, Set: true}}
|
||||
loaded, err := loadProcessInputs(context.Background(), input, commandkit.ReportingModeOrdinary)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
count := 2
|
||||
loaded.Configuration.Config.Application.Chunking.TargetSections = &count
|
||||
_, err = prepareProcess(context.Background(), input, loaded, io.Discard)
|
||||
var selection *preflight.SelectionError
|
||||
if !errors.As(err, &selection) {
|
||||
t.Fatalf("expected selection error, got %v", err)
|
||||
}
|
||||
data, err := os.ReadFile(outputPath)
|
||||
if err != nil || string(data) != "existing" {
|
||||
t.Fatalf("output changed: %q %v", data, err)
|
||||
}
|
||||
for _, name := range []string{"errors.yml", "recoveries.yml", "report.md"} {
|
||||
if _, err := os.Stat(filepath.Join(dir, name)); !os.IsNotExist(err) {
|
||||
t.Fatalf("unexpected report %s: %v", name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user