Add reference catalog selection to pipeline configuration
This commit is contained in:
55
internal/config/reference_catalog_test.go
Normal file
55
internal/config/reference_catalog_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReferenceCatalogImportedOriginsAndSelections(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", `config:
|
||||
imports:
|
||||
- path: catalog/catalog.yml
|
||||
reference_catalog:
|
||||
settings:
|
||||
local: ./local.yml
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.example.test/transcribe
|
||||
`)
|
||||
writePipelineFixture(t, dir, "catalog/catalog.yml", `reference_catalog:
|
||||
settings:
|
||||
sample: ./settings/sample.yml
|
||||
systems:
|
||||
sample: ./systems/sample.yml
|
||||
`)
|
||||
cfg, err := LoadPipeline(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, tc := range []struct{ got, want string }{
|
||||
{cfg.ReferenceCatalog.Settings["sample"], filepath.Join(dir, "catalog/settings/sample.yml")},
|
||||
{cfg.ReferenceCatalog.Settings["local"], filepath.Join(dir, "local.yml")},
|
||||
{cfg.ReferenceCatalog.Systems["sample"], filepath.Join(dir, "catalog/systems/sample.yml")},
|
||||
} {
|
||||
if tc.got != tc.want {
|
||||
t.Fatalf("path %q, want %q", tc.got, tc.want)
|
||||
}
|
||||
}
|
||||
if got, err := cfg.ReferenceCatalog.SelectSetting("sample"); err != nil || got != cfg.ReferenceCatalog.Settings["sample"] {
|
||||
t.Fatalf("selection: %q, %v", got, err)
|
||||
}
|
||||
if _, err := cfg.ReferenceCatalog.SelectSystem("missing"); err == nil || !strings.Contains(err.Error(), "missing") {
|
||||
t.Fatalf("missing selection: %v", err)
|
||||
}
|
||||
if got, err := cfg.ReferenceCatalog.SelectSetting(""); err != nil || got != "" {
|
||||
t.Fatalf("omitted selection: %q, %v", got, err)
|
||||
}
|
||||
b, err := MarshalEffectivePipeline(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(b), "reference_catalog:") || !strings.Contains(string(b), "sample:") {
|
||||
t.Fatalf("catalog omitted from effective snapshot: %s", b)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user