Rename configuration selection to overlays
This commit is contained in:
@@ -77,27 +77,48 @@ func TestDocumentPathsUseInvocationDirectoryForOverrides(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentPathsUseProfileDeclarationDirectory(t *testing.T) {
|
||||
func TestDocumentPathsUseOverlayDeclarationDirectory(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
root := t.TempDir()
|
||||
profiles := filepath.Join(root, "profiles")
|
||||
if err := os.MkdirAll(profiles, 0o700); err != nil {
|
||||
overlays := filepath.Join(root, "overlays")
|
||||
if err := os.MkdirAll(overlays, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
main := filepath.Join(root, "notarius.yml")
|
||||
if err := os.WriteFile(main, []byte("version: 5\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(profiles, "development.yml"), []byte("output: {directory: ./profile-output}\n"), 0o600); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(overlays, "development.yml"), []byte("output: {directory: ./overlay-output}\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := loadConfig(main, LoadOptions{Profile: "development"})
|
||||
loaded, err := loadConfig(main, LoadOptions{Overlay: "development"})
|
||||
if err != nil {
|
||||
t.Fatalf("loadConfig() error = %v", err)
|
||||
}
|
||||
if got := loaded.Config.Output.Directory; got != filepath.Join(profiles, "profile-output") {
|
||||
t.Fatalf("profile directory = %q", got)
|
||||
if got := loaded.Config.Output.Directory; got != filepath.Join(overlays, "overlay-output") {
|
||||
t.Fatalf("overlay directory = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentLoadDoesNotFallBackToLegacyProfileDirectory(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
root := t.TempDir()
|
||||
main := filepath.Join(root, "notarius.yml")
|
||||
if err := os.WriteFile(main, []byte("version: 5\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacy := filepath.Join(root, "profiles", "development.yml")
|
||||
if err := os.MkdirAll(filepath.Dir(legacy), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(legacy, []byte("output: {directory: ./legacy-output}\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := loadConfig(main, LoadOptions{Overlay: "development"}); err == nil {
|
||||
t.Fatal("loadConfig() error = nil, want missing overlay")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
// boundary. It is intentionally narrow: configuration discovery and CLI flag
|
||||
// parsing remain outside this package.
|
||||
type LoadOptions struct {
|
||||
Profile string
|
||||
Overlay string
|
||||
Overrides []configkit.Override
|
||||
InvocationDirectory string
|
||||
}
|
||||
@@ -30,7 +30,7 @@ func loadDocumentWithSource(source configkit.Source, options LoadOptions, import
|
||||
return configkit.Load(source, configkit.Options[Document]{
|
||||
Definition: documentDefinition(state),
|
||||
Imports: imports,
|
||||
Profile: options.Profile,
|
||||
Overlay: options.Overlay,
|
||||
Overrides: options.Overrides,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -105,28 +105,28 @@ debug:
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentLoadDerivesWorkersAfterProfileAndCLIOverrides(t *testing.T) {
|
||||
func TestDocumentLoadDerivesWorkersAfterOverlayAndCLIOverrides(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
directory := t.TempDir()
|
||||
main := filepath.Join(directory, "config.yml")
|
||||
profiles := filepath.Join(directory, "profiles")
|
||||
if err := os.Mkdir(profiles, 0o755); err != nil {
|
||||
overlays := filepath.Join(directory, "overlays")
|
||||
if err := os.Mkdir(overlays, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(main, []byte("version: 5\nconcurrency:\n total_llm: 4\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(profiles, "development.yml"), []byte("concurrency:\n total_llm: 3\n"), 0o600); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(overlays, "development.yml"), []byte("concurrency:\n total_llm: 3\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
profiled, err := loadDocument(main, LoadOptions{Profile: "development"})
|
||||
overlaid, err := loadDocument(main, LoadOptions{Overlay: "development"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if profiled.Config.Concurrency.TotalLLM == nil || *profiled.Config.Concurrency.TotalLLM != 3 || profiled.Config.Concurrency.StageWorkers["extract"] != 3 {
|
||||
t.Fatalf("profiled concurrency = %#v", profiled.Config.Concurrency)
|
||||
if overlaid.Config.Concurrency.TotalLLM == nil || *overlaid.Config.Concurrency.TotalLLM != 3 || overlaid.Config.Concurrency.StageWorkers["extract"] != 3 {
|
||||
t.Fatalf("overlaid concurrency = %#v", overlaid.Config.Concurrency)
|
||||
}
|
||||
|
||||
overridden, err := loadDocument(main, LoadOptions{Overrides: []configkit.Override{{
|
||||
@@ -138,6 +138,16 @@ func TestDocumentLoadDerivesWorkersAfterProfileAndCLIOverrides(t *testing.T) {
|
||||
if overridden.Config.Concurrency.TotalLLM == nil || *overridden.Config.Concurrency.TotalLLM != 2 || overridden.Config.Concurrency.StageWorkers["extract"] != 2 {
|
||||
t.Fatalf("overridden concurrency = %#v", overridden.Config.Concurrency)
|
||||
}
|
||||
|
||||
overlaidAndOverridden, err := loadDocument(main, LoadOptions{Overlay: "development", Overrides: []configkit.Override{{
|
||||
Path: configkit.Keys("concurrency", "total_llm"), Value: 2, Flag: "--total-llm",
|
||||
}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if overlaidAndOverridden.Config.Concurrency.TotalLLM == nil || *overlaidAndOverridden.Config.Concurrency.TotalLLM != 2 || overlaidAndOverridden.Config.Concurrency.StageWorkers["extract"] != 2 {
|
||||
t.Fatalf("overlaid and overridden concurrency = %#v", overlaidAndOverridden.Config.Concurrency)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentLoadRetainsExplicitWorkerAndRejectsInvalidOperationalValues(t *testing.T) {
|
||||
|
||||
@@ -39,7 +39,7 @@ type Invocation struct {
|
||||
InputPath string `json:"input_path,omitempty"`
|
||||
ConfigPath string `json:"config_path,omitempty"`
|
||||
ConfigSource string `json:"config_source,omitempty"`
|
||||
ConfigProfile string `json:"config_profile,omitempty"`
|
||||
ConfigOverlay string `json:"config_overlay,omitempty"`
|
||||
OnlyLanes []string `json:"only_lanes,omitempty"`
|
||||
ChunkCacheOverride string `json:"chunk_cache_override,omitempty"`
|
||||
ReasoningEffortOverride *string `json:"reasoning_effort_override,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user