Skip to content

Commit d935db7

Browse files
committed
Empty array
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent d0e352c commit d935db7

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

pkg/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
9898
// API handlers
9999

100100
func (s *Server) getAgents(c echo.Context) error {
101-
var agents []api.Agent
101+
agents := []api.Agent{}
102102
for k, agentSource := range s.agentSources {
103103
slog.Debug("API source", "source", agentSource.Name())
104104

pkg/server/server_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
)
2222

2323
func TestServer_ListAgents(t *testing.T) {
24-
// t.Parallel()
2524
t.Setenv("OPENAI_API_KEY", "dummy")
2625
t.Setenv("ANTHROPIC_API_KEY", "dummy")
2726

@@ -48,6 +47,14 @@ func TestServer_ListAgents(t *testing.T) {
4847
assert.False(t, agents[2].Multi)
4948
}
5049

50+
func TestServer_EmptyList(t *testing.T) {
51+
ctx := t.Context()
52+
lnPath := startServer(t, ctx, prepareAgentsDir(t))
53+
54+
buf := httpGET(t, ctx, lnPath, "/api/agents")
55+
assert.Equal(t, "[]\n", string(buf)) // We don't want null, but an empty array
56+
}
57+
5158
func TestServer_ListSessions(t *testing.T) {
5259
t.Parallel()
5360

0 commit comments

Comments
 (0)