Add Notarius configuration profile support
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -161,6 +162,45 @@ func TestNotariusCredentialProfileReplacementAndProvenance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusConfigProfileComposition(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
baseValue string
|
||||
overlayName string
|
||||
overlay string
|
||||
want *string
|
||||
}{
|
||||
{name: "omitted"},
|
||||
{name: "explicit empty", baseValue: `""`, want: stringPointer("")},
|
||||
{name: "explicit default", baseValue: "default", want: stringPointer("default")},
|
||||
{name: "base named selection", baseValue: "production", want: stringPointer("production")},
|
||||
{name: "profile replaces named selection", baseValue: "production", overlayName: "testing", overlay: "notarius:\n config_profile: inexpensive\n", want: stringPointer("inexpensive")},
|
||||
{name: "profile clears named selection", baseValue: "production", overlayName: "testing", overlay: "notarius:\n config_profile: null\n"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
rootYAML := "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\nnotarius:\n enabled: false\n"
|
||||
if test.baseValue != "" {
|
||||
rootYAML += " config_profile: " + test.baseValue + "\n"
|
||||
}
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", rootYAML)
|
||||
options := PipelineLoadOptions{}
|
||||
if test.overlayName != "" {
|
||||
writePipelineFixture(t, dir, "profiles/"+test.overlayName+".yml", test.overlay)
|
||||
options.Profile = &test.overlayName
|
||||
}
|
||||
cfg, err := LoadPipelineWithOptions(root, options)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.Notarius == nil || !reflect.DeepEqual(cfg.Notarius.ConfigProfile, test.want) {
|
||||
t.Fatalf("config profile = %#v, want %#v", cfg.Notarius.ConfigProfile, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusCredentialRootProvenance(t *testing.T) {
|
||||
const envName = "NARRATIO_NOTARIUS_ROOT_KEY"
|
||||
t.Setenv(envName, "synthetic-notarius-root-key")
|
||||
|
||||
Reference in New Issue
Block a user