Verify configuration discovery and provenance

This commit is contained in:
2026-11-17 20:53:07 +00:00
parent 349ace0528
commit 8136b4814f
4 changed files with 145 additions and 0 deletions

View File

@@ -271,6 +271,41 @@ func TestRunAppliesConfigurationOverlayAndRecordsSelection(t *testing.T) {
}
}
func TestRunRecordsDiscoveredConfigurationPath(t *testing.T) {
roots := newStateTestRoots(t)
work := t.TempDir()
selected := filepath.Join(work, "notarius.yml")
data, err := os.ReadFile(roots.config)
if err != nil {
t.Fatal(err)
}
if err := os.WriteFile(selected, data, 0600); err != nil {
t.Fatal(err)
}
previous, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
if err := os.Chdir(work); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
if err := os.Chdir(previous); err != nil {
t.Error(err)
}
})
var stdout, stderr bytes.Buffer
code := RunWithOptions([]string{"run", "sample", "--input", roots.input, "--chunk_cache", "bypass", "--debug"}, &stdout, &stderr, newStateTestHarness().options())
if code != 0 {
t.Fatalf("code=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String())
}
var invocation debugbundle.Invocation
readStateTestSummaryJSON(t, onlyChildDir(t, roots.debug), "invocation.json", &invocation)
if invocation.ConfigPath != selected {
t.Fatalf("recorded config path = %q, want %q", invocation.ConfigPath, selected)
}
}
func TestEffectiveConfigOverlayOmitsBaseSelection(t *testing.T) {
for _, overlay := range []string{"", "default"} {
if got := effectiveConfigOverlay(overlay); got != "" {