Add typed Notarius cache controls
This commit is contained in:
@@ -182,6 +182,57 @@ func TestNotariusCredentialRootProvenance(t *testing.T) {
|
||||
t.Fatal("Notarius credential provenance did not identify the root pipeline")
|
||||
}
|
||||
|
||||
func TestNotariusCacheControlProfileReplacementAndNullReset(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
overlay string
|
||||
wantResume bool
|
||||
wantMode string
|
||||
wantSource bool
|
||||
wantNil bool
|
||||
}{
|
||||
{name: "replacement", overlay: "notarius:\n resume: true\n chunk_cache: refresh\n", wantResume: true, wantMode: "refresh", wantSource: true},
|
||||
{name: "null reset", overlay: "notarius: null\n", wantNil: true},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\nnotarius:\n enabled: false\n resume: false\n chunk_cache: bypass\n")
|
||||
overlay := writePipelineFixture(t, dir, "profiles/testing.yml", test.overlay)
|
||||
profile := "testing"
|
||||
cfg, err := LoadPipelineWithOptions(root, PipelineLoadOptions{Profile: &profile})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if test.wantNil {
|
||||
if cfg.Notarius != nil {
|
||||
t.Fatalf("Notarius = %#v, want null reset", cfg.Notarius)
|
||||
}
|
||||
return
|
||||
}
|
||||
if cfg.Notarius == nil || cfg.Notarius.Resume != test.wantResume || cfg.Notarius.ChunkCache != test.wantMode {
|
||||
t.Fatalf("cache controls = resume %v, mode %q; want resume %v, mode %q", cfg.Notarius.Resume, cfg.Notarius.ChunkCache, test.wantResume, test.wantMode)
|
||||
}
|
||||
if !test.wantSource {
|
||||
return
|
||||
}
|
||||
sources, err := EffectivePipelineSources(cfg, ResolvedParty{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
found := map[string]bool{}
|
||||
for _, source := range sources {
|
||||
if source.Path == "notarius.resume" || source.Path == "notarius.chunk_cache" {
|
||||
found[source.Path] = source.Source == overlay
|
||||
}
|
||||
}
|
||||
if !found["notarius.resume"] || !found["notarius.chunk_cache"] {
|
||||
t.Fatalf("cache-control provenance did not identify profile: %#v", found)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPipelineConfigKitAllowsOneBaseDeclarationWithProfileOverride(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writePipelineFixture(t, dir, "pipeline.yml", `configkit:
|
||||
|
||||
Reference in New Issue
Block a user