mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-09-03 00:17:57 +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.
38 lines
1000 B
Go
38 lines
1000 B
Go
//go:build integration
|
|
|
|
package ws_methods
|
|
|
|
import "testing"
|
|
|
|
// CONTRACT: agents.list response MUST include agents array with required fields.
|
|
func TestContract_WS_AgentsList(t *testing.T) {
|
|
wsURL, _ := getTestServer(t)
|
|
client, _ := connect(t, wsURL, nil)
|
|
|
|
resp := client.send(t, "agents.list", map[string]any{})
|
|
|
|
// Response must have agents array
|
|
assertField(t, resp, "agents", "array")
|
|
|
|
// If agents exist, verify each has required fields
|
|
agents, ok := resp["agents"].([]any)
|
|
if !ok || len(agents) == 0 {
|
|
t.Log("No agents returned - skipping field checks")
|
|
return
|
|
}
|
|
|
|
agent, ok := agents[0].(map[string]any)
|
|
if !ok {
|
|
t.Error("CONTRACT VIOLATION: agents[0] is not an object")
|
|
return
|
|
}
|
|
|
|
// Required agent fields
|
|
assertField(t, agent, "id", "string")
|
|
assertField(t, agent, "agent_key", "string")
|
|
assertField(t, agent, "display_name", "string")
|
|
assertField(t, agent, "status", "string")
|
|
assertField(t, agent, "provider", "string")
|
|
assertField(t, agent, "model", "string")
|
|
}
|