Add semantic configuration profile comparison
This commit is contained in:
@@ -318,6 +318,43 @@ whisperx:
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectivePipelineValuesIgnoreEquivalentSourceLayout(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
monolithicPath := writePipelineSource(t, dir, "monolithic.yml", `workspace:
|
||||
root: /srv/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.example.com/transcribe
|
||||
language: en
|
||||
`)
|
||||
composedPath := writePipelineSource(t, dir, "pipeline.yml", `composition:
|
||||
imports: [workspace.yml]
|
||||
whisperx:
|
||||
language: en
|
||||
transcribe_url: https://transcription.example.com/transcribe
|
||||
`)
|
||||
writePipelineSource(t, dir, "workspace.yml", "workspace:\n root: /srv/narratio\n")
|
||||
|
||||
monolithic, err := LoadPipeline(monolithicPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
composed, err := LoadPipeline(composedPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
monolithicValues, err := EffectivePipelineValues(monolithic)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
composedValues, err := EffectivePipelineValues(composed)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(monolithicValues, composedValues) {
|
||||
t.Fatalf("equivalent effective values differ:\nmonolithic=%#v\ncomposed=%#v", monolithicValues, composedValues)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPipelineEffectiveDigestExcludesProfileIdentity(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
rootPath := writeProfilePipeline(t, dir, profileComposition("production", "production", "testing"))
|
||||
@@ -340,6 +377,53 @@ func TestPipelineEffectiveDigestExcludesProfileIdentity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadPipelineProfilePairResolvesIndependentEffectivePipelines(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
rootPath := writeProfilePipeline(t, dir, `composition:
|
||||
imports: [base.yml]
|
||||
default_profile: production
|
||||
profiles:
|
||||
production:
|
||||
overlay: production.yml
|
||||
testing:
|
||||
overlay: testing.yml
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.example.com/transcribe
|
||||
`)
|
||||
writePipelineSource(t, dir, "base.yml", "workspace:\n root: /srv/base\n")
|
||||
writePipelineSource(t, dir, "production.yml", "workspace:\n root: /srv/production\nwhisperx:\n language: en\n")
|
||||
writePipelineSource(t, dir, "testing.yml", "workspace:\n root: /srv/testing\nwhisperx:\n language: fr\n")
|
||||
|
||||
production, testing, err := LoadPipelineProfilePair(rootPath, "production", "testing")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if production.Workspace.Root != "/srv/production" || production.WhisperX.Language != "en" {
|
||||
t.Fatalf("production pair result = %#v", production)
|
||||
}
|
||||
if testing.Workspace.Root != "/srv/testing" || testing.WhisperX.Language != "fr" {
|
||||
t.Fatalf("testing pair result = %#v", testing)
|
||||
}
|
||||
production.Workspace.Root = "/mutated-left"
|
||||
if testing.Workspace.Root != "/srv/testing" {
|
||||
t.Fatalf("right profile shared mutable state with left: %q", testing.Workspace.Root)
|
||||
}
|
||||
testingFirst, productionSecond, err := LoadPipelineProfilePair(rootPath, "testing", "production")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if testingFirst.Workspace.Root != "/srv/testing" || productionSecond.Workspace.Root != "/srv/production" {
|
||||
t.Fatalf("reversed profile pair = testing=%q production=%q", testingFirst.Workspace.Root, productionSecond.Workspace.Root)
|
||||
}
|
||||
|
||||
if _, _, err := LoadPipelineProfilePair(rootPath, "production", "production"); err == nil || !strings.Contains(err.Error(), "must differ") {
|
||||
t.Fatalf("equal profile pair error = %v, want selection rejection", err)
|
||||
}
|
||||
if _, _, err := LoadPipelineProfilePair(rootPath, "unknown", "testing"); err == nil || !strings.Contains(err.Error(), "not declared") {
|
||||
t.Fatalf("unknown profile pair error = %v, want selection rejection", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadWithSessionOptionsCarriesExplicitProfilePresence(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
rootPath := writeProfilePipeline(t, dir, profileComposition("production", "production", "testing"))
|
||||
|
||||
Reference in New Issue
Block a user