Files
viettranx e788e621c3 test(contracts): add P1 WS and HTTP API contract tests
WS contract tests:
- connect: verify response schema (protocol, role, user_id, tenant_id, is_owner, server)
- agents.list: verify agents array with required fields (id, agent_key, display_name)

HTTP contract tests:
- /v1/chat/completions: verify OpenAI-compatible response (id, object, choices, usage)

Tests require CONTRACT_TEST_WS_URL, CONTRACT_TEST_HTTP_URL, CONTRACT_TEST_TOKEN env vars.
2026-04-12 21:44:32 +07:00

33 lines
902 B
Go

//go:build integration
package ws_methods
import (
"testing"
"github.com/nextlevelbuilder/goclaw/pkg/protocol"
)
// CONTRACT: connect response MUST include these fields with correct types.
// Breaking changes require protocol version bump.
func TestContract_WS_Connect(t *testing.T) {
wsURL, _ := getTestServer(t)
_, resp := connect(t, wsURL, nil)
// Required fields
assertField(t, resp, "protocol", "number")
assertField(t, resp, "role", "string")
assertField(t, resp, "user_id", "string")
assertField(t, resp, "tenant_id", "string")
assertField(t, resp, "is_owner", "bool")
// Nested server object
assertField(t, resp, "server", "object")
assertField(t, resp, "server.name", "string")
assertField(t, resp, "server.version", "string")
// Value checks
assertFieldValue(t, resp, "protocol", float64(protocol.ProtocolVersion))
assertFieldValue(t, resp, "server.name", "goclaw")
}