41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
|
|
package app
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bytes"
|
||
|
|
"context"
|
||
|
|
"path/filepath"
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestConfigDiffUsesEscapedPointersAndAtomicLists(t *testing.T) {
|
||
|
|
dir := t.TempDir()
|
||
|
|
root := filepath.Join(dir, "pipeline.yml")
|
||
|
|
mustWriteTestFile(t, root, "whisperx: {transcribe_url: 'https://example.test/transcribe'}\nscriptorium:\n artifacts:\n recap:\n enabled: false\n output_path: artifacts/recap.md\n vars: {'a/b~c': before}\naudita: {modules: [glossary, grammar]}\n")
|
||
|
|
mustWriteTestFile(t, filepath.Join(dir, "overlays", "changed.yml"), "scriptorium:\n artifacts:\n recap:\n vars: {'a/b~c': after}\naudita: {modules: [glossary, homophones]}\n")
|
||
|
|
var output bytes.Buffer
|
||
|
|
if err := ConfigDiff(context.Background(), []string{"default", "changed", "--config", root}, &output); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
for _, want := range []string{"changed\t/audita/modules\t[\"glossary\",\"grammar\"]\t[\"glossary\",\"homophones\"]", "changed\t/scriptorium/artifacts/recap/vars/a~1b~0c\t\"before\"\t\"after\""} {
|
||
|
|
if !strings.Contains(output.String(), want) {
|
||
|
|
t.Fatalf("diff lacks %q: %s", want, output.String())
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestConfigSourcesReportsEmptyOptionalImportAndNormalization(t *testing.T) {
|
||
|
|
dir := t.TempDir()
|
||
|
|
root := filepath.Join(dir, "pipeline.yml")
|
||
|
|
mustWriteTestFile(t, root, "config:\n imports:\n - path: absent.yml\nworkspace: {root: ./work}\nwhisperx: {transcribe_url: 'https://example.test/transcribe'}\n")
|
||
|
|
var output bytes.Buffer
|
||
|
|
if err := ConfigSources(context.Background(), []string{"--config", root}, &output); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
for _, want := range []string{"empty_import\t/config/imports/0\tpath\t" + root, "workspace.root\tresolution\tresolution", "workspace.root\troot\t" + root} {
|
||
|
|
if !strings.Contains(output.String(), want) {
|
||
|
|
t.Fatalf("sources lack %q: %s", want, output.String())
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|