79 lines
2.5 KiB
Go
79 lines
2.5 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/core/diagnostics"
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
|
)
|
|
|
|
func TestDefaultValues(t *testing.T) {
|
|
cfg := Default()
|
|
|
|
defaultProfile, ok := cfg.LLMProfiles[pipeline.DefaultLLMProfile]
|
|
if !ok {
|
|
t.Fatalf("expected default LLM profile")
|
|
}
|
|
if defaultProfile.Provider != "openai-compatible" {
|
|
t.Fatalf("unexpected provider: %q", defaultProfile.Provider)
|
|
}
|
|
if defaultProfile.BaseURL != "" || defaultProfile.Model != "" {
|
|
t.Fatalf("default profile should not require base URL/model yet: %+v", defaultProfile)
|
|
}
|
|
if defaultProfile.TimeoutSeconds != 600 || defaultProfile.MaxRetries != 3 || defaultProfile.MaxConcurrency != 1 {
|
|
t.Fatalf("unexpected default LLM operational values: %+v", defaultProfile)
|
|
}
|
|
if len(cfg.Pipelines) != 0 {
|
|
t.Fatalf("expected no built-in pipeline profiles, got %v", cfg.Pipelines)
|
|
}
|
|
if cfg.Concurrency.TotalLLM != 1 {
|
|
t.Fatalf("unexpected total LLM concurrency: %d", cfg.Concurrency.TotalLLM)
|
|
}
|
|
if cfg.Diagnostics.WorkDir != "/tmp/notarius" {
|
|
t.Fatalf("unexpected diagnostics work dir: %q", cfg.Diagnostics.WorkDir)
|
|
}
|
|
if cfg.Diagnostics.Retention != diagnostics.RetentionAuto {
|
|
t.Fatalf("unexpected diagnostics retention: %q", cfg.Diagnostics.Retention)
|
|
}
|
|
}
|
|
|
|
func TestApplyFileConfigMergesWithDefaults(t *testing.T) {
|
|
fileCfg, err := ParseFileConfigYAML([]byte(`
|
|
version: 1
|
|
llm_profiles:
|
|
default:
|
|
model: test-model
|
|
pipelines:
|
|
example:
|
|
input: fake/input
|
|
artifacts:
|
|
events:
|
|
extract: fake/extract
|
|
`))
|
|
if err != nil {
|
|
t.Fatalf("ParseFileConfigYAML: %v", err)
|
|
}
|
|
|
|
cfg := Default()
|
|
if err := cfg.applyFileConfigWithLookup(fileCfg, emptyLookup); err != nil {
|
|
t.Fatalf("ApplyFileConfig: %v", err)
|
|
}
|
|
|
|
profile := cfg.LLMProfiles[pipeline.DefaultLLMProfile]
|
|
if profile.Model != "test-model" {
|
|
t.Fatalf("expected file model, got %+v", profile)
|
|
}
|
|
if profile.Provider != "openai-compatible" || profile.TimeoutSeconds != 600 || profile.MaxRetries != 3 {
|
|
t.Fatalf("expected default LLM fields to be preserved, got %+v", profile)
|
|
}
|
|
if cfg.Concurrency.TotalLLM != 1 {
|
|
t.Fatalf("expected default concurrency preserved, got %d", cfg.Concurrency.TotalLLM)
|
|
}
|
|
if cfg.Diagnostics.Retention != diagnostics.RetentionAuto {
|
|
t.Fatalf("expected default diagnostics retention preserved, got %q", cfg.Diagnostics.Retention)
|
|
}
|
|
if _, ok := cfg.Pipelines["example"]; !ok {
|
|
t.Fatalf("expected file pipeline to be applied")
|
|
}
|
|
}
|