package api
import (
"os"
"testing"
"craftdesign.group/quarry/internal/ops"
)
// TestDocsCurrent is the documentation exit criterion (0003): docs/api.md
// must match what the registry generates. Regenerate with `make docs`.
func TestDocsCurrent(t *testing.T) {
r := ops.NewRegistry()
// A non-nil Chat plane, same as cmd/quarry's docs/spec generation
// uses (docsChatPlane there): RegisterAll gates chat.* on Deps.Chat
// != nil, and this reference registry has to match what actually
// gets documented or every chat op reads as permanently stale.
if err := RegisterAll(r, Deps{Version: "v", Chat: &fakeChat{}}); err != nil {
t.Fatal(err)
}
want := ops.Docs(r, "quarry")
got, err := os.ReadFile("../../docs/api.md")
if err != nil {
t.Fatalf("docs/api.md unreadable (run `make docs`): %v", err)
}
if string(got) != string(want) {
t.Fatal("docs/api.md is stale — run `make docs` and commit the result")
}
}