ca243a2d50
executus CI / test (push) Failing after 24s
Batteries-included agent-harness base, extracted from mort's agent layer. This first cut establishes the module + the zero-coupling core primitives: - lane, dispatchguard, pendingattach, run/progress.go: moved verbatim from mort - config: host config Source seam + env-var default (nil-safe helpers) - deliver: output-egress seam + Discard/Stdout defaults - identity: AdminPolicy + MemberResolver seams (nil-safe) - fanout: programmatic N×M swarm (bounded global + per-key concurrency) - README/CLAUDE.md with the vibe-coded banner; CI with Go gates + the "core stays majordomo+stdlib only" invariant Core builds with stdlib only today; majordomo enters at P1 (model/structured). go build/vet/test -race all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestEnvNameMapping(t *testing.T) {
|
|
e := envSource{prefix: "GADFLY_"}
|
|
cases := map[string]string{
|
|
"models": "GADFLY_MODELS",
|
|
"model.tier.fast.max_steps": "GADFLY_MODEL_TIER_FAST_MAX_STEPS",
|
|
"provider-concurrency": "GADFLY_PROVIDER_CONCURRENCY",
|
|
"a/b.c": "GADFLY_A_B_C",
|
|
}
|
|
for key, want := range cases {
|
|
if got := e.envName(key); got != want {
|
|
t.Errorf("envName(%q) = %q, want %q", key, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestEnvReadsAndDefaults(t *testing.T) {
|
|
t.Setenv("EX_MODELS", "a,b,c")
|
|
t.Setenv("EX_MAX", "12")
|
|
t.Setenv("EX_RATIO", "0.7")
|
|
t.Setenv("EX_ON", "true")
|
|
t.Setenv("EX_BLANK", "")
|
|
s := Env("EX_")
|
|
|
|
if got := s.String("models", "def"); got != "a,b,c" {
|
|
t.Errorf("String = %q", got)
|
|
}
|
|
if got := s.String("blank", "def"); got != "def" {
|
|
t.Errorf("blank String should fall back to default, got %q", got)
|
|
}
|
|
if got := s.String("missing", "def"); got != "def" {
|
|
t.Errorf("missing String = %q", got)
|
|
}
|
|
if got := s.Int("max", 1); got != 12 {
|
|
t.Errorf("Int = %d", got)
|
|
}
|
|
if got := s.Int("models", 1); got != 1 {
|
|
t.Errorf("unparseable Int should default, got %d", got)
|
|
}
|
|
if got := s.Float("ratio", 1); got != 0.7 {
|
|
t.Errorf("Float = %v", got)
|
|
}
|
|
if got := s.Bool("on", false); got != true {
|
|
t.Errorf("Bool = %v", got)
|
|
}
|
|
}
|
|
|
|
func TestNilSafeHelpers(t *testing.T) {
|
|
var s Source // nil
|
|
if String(s, "k", "d") != "d" || Int(s, "k", 7) != 7 || Float(s, "k", 1.5) != 1.5 || !Bool(s, "k", true) {
|
|
t.Fatal("nil Source helpers must return defaults")
|
|
}
|
|
}
|