78 lines
2.4 KiB
Go
78 lines
2.4 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/core/diagnostics"
|
|
)
|
|
|
|
func TestDefaultValues(t *testing.T) {
|
|
cfg := Default()
|
|
|
|
if cfg.Scriptorium.ProfileDir != "" || cfg.Scriptorium.ProfileFile != "" {
|
|
t.Fatalf("unexpected Scriptorium profile source defaults: %+v", cfg.Scriptorium)
|
|
}
|
|
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)
|
|
}
|
|
if cfg.Workspace.Directory != "" {
|
|
t.Fatalf("unexpected workspace directory: %q", cfg.Workspace.Directory)
|
|
}
|
|
if !cfg.Workspace.Diagnostics.Enabled || !cfg.DiagnosticsEnabled() {
|
|
t.Fatalf("expected workspace diagnostics enabled by default: %+v", cfg.Workspace.Diagnostics)
|
|
}
|
|
if cfg.Workspace.Diagnostics.Retention != "" {
|
|
t.Fatalf("unexpected workspace diagnostics retention: %q", cfg.Workspace.Diagnostics.Retention)
|
|
}
|
|
if cfg.Workspace.Resume.Enabled {
|
|
t.Fatalf("workspace resume should be disabled by default")
|
|
}
|
|
if cfg.Workspace.Debug.Enabled {
|
|
t.Fatalf("workspace debug should be disabled by default")
|
|
}
|
|
}
|
|
|
|
func TestApplyFileConfigMergesWithDefaults(t *testing.T) {
|
|
fileCfg, err := ParseFileConfigYAML([]byte(`
|
|
version: 2
|
|
scriptorium:
|
|
profile_dir: ./profiles
|
|
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)
|
|
}
|
|
|
|
if cfg.Scriptorium.ProfileDir != "./profiles" {
|
|
t.Fatalf("expected Scriptorium profile dir, got %+v", cfg.Scriptorium)
|
|
}
|
|
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")
|
|
}
|
|
}
|