Implemented shared S3 audio caching for prepare and restore --include-audio
This commit is contained in:
67
internal/config/cache_config_test.go
Normal file
67
internal/config/cache_config_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCacheDefaults(t *testing.T) {
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://example.com/transcribe
|
||||
analyzer:
|
||||
timeout: 20m
|
||||
notification:
|
||||
timeout: 10s
|
||||
`, `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
`)
|
||||
cfg, err := Load(pipelinePath, sessionPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
if cfg.Pipeline.Cache.Root != DefaultCacheRoot {
|
||||
t.Fatalf("cache.root = %q, want %q", cfg.Pipeline.Cache.Root, DefaultCacheRoot)
|
||||
}
|
||||
if cfg.Pipeline.Cache.S3Audio == nil || *cfg.Pipeline.Cache.S3Audio != DefaultCacheS3Audio {
|
||||
t.Fatalf("cache.s3_audio = %v, want %v", cfg.Pipeline.Cache.S3Audio, DefaultCacheS3Audio)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCacheStrictDecodeRejectsUnknownFields(t *testing.T) {
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, `workspace:
|
||||
root: /tmp/narratio
|
||||
cache:
|
||||
root: /var/cache/narratio
|
||||
unknown: true
|
||||
`, `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
`)
|
||||
_, err := Load(pipelinePath, sessionPath)
|
||||
if err == nil || !strings.Contains(err.Error(), "strict decode failed") {
|
||||
t.Fatalf("Load() error = %v, want strict decode failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCacheValidationRequiresRootWhenS3AudioEnabled(t *testing.T) {
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, `workspace:
|
||||
root: /tmp/narratio
|
||||
cache:
|
||||
root: " "
|
||||
s3_audio: true
|
||||
`, `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
`)
|
||||
cfg, err := Load(pipelinePath, sessionPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
err = Validate(cfg)
|
||||
if err == nil || !strings.Contains(err.Error(), "pipeline.cache.root is required") {
|
||||
t.Fatalf("Validate() error = %v, want cache root error", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user