66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
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
|
|
notification:
|
|
mode: noop
|
|
`, `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)
|
|
}
|
|
}
|