Completes FLUID-WP-0008's deliverable in this repository. The handover records the measured pressure that motivates the interface -- 80 of 94 hall entries exceed Telegram's 4096-character limit -- and names the three places this workload will strain the framework honestly, so the strain reads as information rather than as a surprise. A conformance test asserts the handover's contract compiles with fluid-core's own validator and stays within the intent's complexity budget, so a change on either side that broke the handover fails CI rather than failing at the first publication. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014KmVxhJ35tCo7rE7UnLwWu Assistant: claude-code Assistant-Model: opus Assistant-Process: 1116572@bnt-lap001 Assistant-Session: 8ba9bb93-a72a-4883-b189-2499cce5c400
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package conformance
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/tegwick/fluid-core/internal/validate"
|
|
)
|
|
|
|
// TestTelegramHandoverContractCompiles checks that the contract shipped in the
|
|
// fluid-telegram handover is one this gateway can actually enforce.
|
|
//
|
|
// A handover that shipped a contract the framework cannot parse would fail at
|
|
// the first publication, after the bot and channel had already been created.
|
|
// The check is skipped when the sibling repository is absent, so CI in a bare
|
|
// checkout still passes.
|
|
func TestTelegramHandoverContractCompiles(t *testing.T) {
|
|
const path = "../../fluid-telegram/contracts/r1.openapi.yaml"
|
|
|
|
raw, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Skipf("fluid-telegram not checked out beside fluid-core: %v", err)
|
|
}
|
|
|
|
c, err := validate.ParseOpenAPI(raw)
|
|
if err != nil {
|
|
t.Fatalf("the handover contract does not compile: %v", err)
|
|
}
|
|
|
|
ops := c.Operations()
|
|
want := map[string]bool{
|
|
"GET /v1/hall-entries": false,
|
|
"POST /v1/hall-entries": false,
|
|
"GET /v1/hall-entries/{entry_id}": false,
|
|
}
|
|
for _, op := range ops {
|
|
if _, tracked := want[op]; tracked {
|
|
want[op] = true
|
|
}
|
|
}
|
|
for op, found := range want {
|
|
if !found {
|
|
t.Errorf("the contract does not declare %s; it has %v", op, ops)
|
|
}
|
|
}
|
|
|
|
// The interface's complexity budget allows a maximum of 8 operations.
|
|
if len(ops) > 8 {
|
|
t.Errorf("the contract declares %d operations, over the intent's budget of 8", len(ops))
|
|
}
|
|
}
|