From cc21384ff42bb361a1f1971aa443bc7636faf901 Mon Sep 17 00:00:00 2001 From: viettranx Date: Sun, 12 Apr 2026 21:46:48 +0700 Subject: [PATCH] test(contracts): add /v1/agents HTTP contract test --- tests/contracts/http_api/agents_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/contracts/http_api/agents_test.go diff --git a/tests/contracts/http_api/agents_test.go b/tests/contracts/http_api/agents_test.go new file mode 100644 index 00000000..8935bf59 --- /dev/null +++ b/tests/contracts/http_api/agents_test.go @@ -0,0 +1,25 @@ +//go:build integration + +package http_api + +import "testing" + +// CONTRACT: /v1/agents response MUST include agents array. +func TestContract_HTTP_AgentsList(t *testing.T) { + baseURL, token := getTestServer(t) + client := newHTTPClient(baseURL, token) + + resp := client.get(t, "/v1/agents") + + assertField(t, resp, "agents", "array") + + agents, ok := resp["agents"].([]any) + if !ok || len(agents) == 0 { + t.Log("No agents - skipping field checks") + return + } + + agent := agents[0].(map[string]any) + assertField(t, agent, "id", "string") + assertField(t, agent, "agent_key", "string") +}