Keep one verified copy of session audio
This commit is contained in:
@@ -4,47 +4,14 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"go.maximumdirect.net/commandkit"
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
)
|
||||
|
||||
func TestCleanCommandReportsCompletedActionsBeforeLaterFailure(t *testing.T) {
|
||||
workspace := t.TempDir()
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, workspace)
|
||||
work := artifacts.SessionWorkDirForCampaign(workspace, "sample-campaign", "2026-05-03")
|
||||
mustWriteTestFile(t, filepath.Join(work, "manifest.json"), "{}")
|
||||
spool := artifacts.SessionSpoolDir(filepath.Join(workspace, "spool"), "sample-campaign", "2026-05-03")
|
||||
if err := os.MkdirAll(filepath.Dir(spool), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outside := t.TempDir()
|
||||
sentinel := filepath.Join(outside, "retained")
|
||||
mustWriteTestFile(t, sentinel, "retained")
|
||||
if err := os.Symlink(outside, spool); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out, diagnostic bytes.Buffer
|
||||
outcome := Execute(context.Background(), []string{"session", "clean", "2026-05-03", "--config", pipeline, "--campaign-file", campaign, "--session-file", session, "--format", "json"}, commandkit.Streams{Out: &out, Err: &diagnostic})
|
||||
if outcome.Status != 1 {
|
||||
t.Fatalf("status=%d diagnostics=%s", outcome.Status, diagnostic.String())
|
||||
}
|
||||
var report cleanCommandReport
|
||||
if err := json.Unmarshal(out.Bytes(), &report); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if report.Complete || len(report.Actions) != 2 || report.Actions[0].Status != "deleted" || report.Actions[1].Status != "failed" || report.Error == "" {
|
||||
t.Fatalf("partial report=%#v", report)
|
||||
}
|
||||
cleanAssertMissing(t, work)
|
||||
cleanAssertExists(t, sentinel)
|
||||
}
|
||||
|
||||
func TestCleanCommandChecksAllSelectionBeforeBootstrap(t *testing.T) {
|
||||
app, err := newApplication(commandDependencies{
|
||||
preparePipelineSource: func(configkit.Source) (*configkit.SecretsReport, configkit.Source, error) {
|
||||
@@ -80,7 +47,7 @@ func TestCleanCommandChecksAllSelectionBeforeBootstrap(t *testing.T) {
|
||||
func TestCleanAllCommandNeedsOnlyPipelineConfiguration(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
pipeline := filepath.Join(root, "pipeline.yml")
|
||||
mustWriteTestFile(t, pipeline, "workspace: {root: ./workspace}\nspool: {root: ./spool}\nwhisperx: {transcribe_url: https://transcription.example.test/transcribe}\n")
|
||||
mustWriteTestFile(t, pipeline, "workspace: {root: ./workspace}\nwhisperx: {transcribe_url: https://transcription.example.test/transcribe}\n")
|
||||
var out, diagnostic bytes.Buffer
|
||||
outcome := Execute(context.Background(), []string{"session", "clean", "--all", "--dry-run", "--config", pipeline, "--format", "json"}, commandkit.Streams{Out: &out, Err: &diagnostic})
|
||||
if outcome.Status != 0 {
|
||||
@@ -90,7 +57,7 @@ func TestCleanAllCommandNeedsOnlyPipelineConfiguration(t *testing.T) {
|
||||
if err := json.Unmarshal(out.Bytes(), &report); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !report.All || !report.DryRun || report.Complete || report.Campaign != "" || report.Cache != "preserved" {
|
||||
if !report.All || !report.DryRun || report.Complete || report.Campaign != "" {
|
||||
t.Fatalf("report=%#v", report)
|
||||
}
|
||||
cleanAssertMissing(t, filepath.Join(root, "workspace"))
|
||||
|
||||
Reference in New Issue
Block a user