f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"go.kenn.io/agentsview/internal/db"
|
|
)
|
|
|
|
func TestHandlers_Internal_DeadlineExceeded(t *testing.T) {
|
|
t.Parallel()
|
|
s := testServer(t, 30*time.Second)
|
|
|
|
// Seed a session just in case handlers check for existence before context.
|
|
started := "2025-01-15T10:00:00Z"
|
|
sess := db.Session{
|
|
ID: "s1",
|
|
Project: "test-proj",
|
|
StartedAt: &started,
|
|
}
|
|
require.NoError(t, s.db.UpsertSession(sess))
|
|
|
|
tests := []struct {
|
|
name string
|
|
path string
|
|
requiresFTS bool
|
|
}{
|
|
{"ListSessions", "/api/v1/sessions", false},
|
|
{"GetSession", "/api/v1/sessions/s1", false},
|
|
{"GetMessages", "/api/v1/sessions/s1/messages", false},
|
|
{"GetStats", "/api/v1/stats", false},
|
|
{"ListProjects", "/api/v1/projects", false},
|
|
{"ListMachines", "/api/v1/machines", false},
|
|
{"Search", "/api/v1/search?q=test", true},
|
|
{"GetSessionActivity", "/api/v1/sessions/s1/activity", false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
if tt.requiresFTS && !s.db.HasFTS() {
|
|
t.Skip("skipping test: no FTS support")
|
|
}
|
|
ctx, cancel := expiredCtx(t)
|
|
defer cancel()
|
|
|
|
req := httptest.NewRequest(http.MethodGet, tt.path, nil)
|
|
req = req.WithContext(ctx)
|
|
|
|
w := httptest.NewRecorder()
|
|
|
|
s.mux.ServeHTTP(w, req)
|
|
|
|
assertRecorderStatus(t, w, http.StatusGatewayTimeout)
|
|
assertContentType(t, w, "application/json")
|
|
})
|
|
}
|
|
}
|