Merge pull request #879 from samcharles93/fix/docs-ci-and-overlay-coverage

fix(ci): unbreak the docs workflow, and cover nested config-overlay merge
This commit is contained in:
sam authored and GitHub committed 2026-09-19 02:41:37 +10:00
commit 080dd1d90b
2 files changed
+55 -1

No files matched your search

+6 -1
View File
@@ -30,10 +30,15 @@ jobs:
steps:
- uses: actions/checkout@v5
# No `cache: pip` here: this repository is Go and has no
# requirements.txt or pyproject.toml for setup-python to hash. Asking for
# a pip cache makes the step fail outright with "No file ... matched to
# [**/requirements.txt or **/pyproject.toml]", so every docs-touching PR
# failed before `mkdocs build --strict` ever ran -- which also meant the
# strict link/config check silently stopped guarding anything.
- uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: pip
- run: pip install mkdocs-material
@@ -30,6 +30,55 @@ func TestApplyOverlayValuesFieldLevelMerge(t *testing.T) {
}
}
// TestApplyOverlayValuesPreservesOmittedNestedFields pins ApplyOverlayValues'
// documented promise -- "only the keys present are replaced, every field the
// overlay omits keeps its existing value" -- at the depth where it matters.
//
// The concrete risk is services.state: an overlay that changes only the target
// must not clear target_token, because dropping the token silently removes
// authentication for a non-loopback State Store. The existing field-level test
// only covers one level (budgets.max_steps); these cases go two levels deep into
// a struct of structs, which is the shape Services has.
func TestApplyOverlayValuesPreservesOmittedNestedFields(t *testing.T) {
tests := []struct {
name string
start config.Services
overlay map[string]any
want config.Services
}{
{
name: "target-only overlay keeps the token",
start: config.Services{State: config.ServiceConnection{Target: "127.0.0.1:50051", TargetToken: "secret"}},
overlay: map[string]any{"services": map[string]any{"state": map[string]any{"target": "10.0.0.5:50051"}}},
want: config.Services{State: config.ServiceConnection{Target: "10.0.0.5:50051", TargetToken: "secret"}},
},
{
name: "token-only overlay keeps the target",
start: config.Services{State: config.ServiceConnection{Target: "10.0.0.5:50051", TargetToken: "old"}},
overlay: map[string]any{"services": map[string]any{"state": map[string]any{"target_token": "rotated"}}},
want: config.Services{State: config.ServiceConnection{Target: "10.0.0.5:50051", TargetToken: "rotated"}},
},
{
name: "sibling service is untouched",
start: config.Services{Gateway: config.ServiceConnection{Target: "127.0.0.1:50052"}, State: config.ServiceConnection{Target: "a", TargetToken: "t"}},
overlay: map[string]any{"services": map[string]any{"state": map[string]any{"target": "b"}}},
want: config.Services{Gateway: config.ServiceConnection{Target: "127.0.0.1:50052"}, State: config.ServiceConnection{Target: "b", TargetToken: "t"}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := config.Config{Services: tt.start}
if err := ApplyOverlayValues(&cfg, tt.overlay); err != nil {
t.Fatalf("ApplyOverlayValues: %v", err)
}
if cfg.Services != tt.want {
t.Errorf("Services = %+v, want %+v", cfg.Services, tt.want)
}
})
}
}
func TestLoaderApplyOverlayLayersDefaultsValidatesAndRecordsProvenance(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.toml")
if err := os.WriteFile(path, []byte("bot_user = \"widget\"\n[[repos]]\nowner = \"acme\"\nname = \"app\"\n"), 0o600); err != nil {