mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-08-06 20:25:10 +00:00
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.
33 lines
902 B
Go
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")
|
|
}
|