Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:30:36 +08:00

40 lines
1.1 KiB
Go

package server_test
import (
"encoding/json"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.kenn.io/agentsview/internal/db"
)
func TestGetSessionActivity(t *testing.T) {
te := setup(t)
te.seedSession(t, "s1", "my-app", 10)
te.seedMessages(t, "s1", 10)
w := te.get(t, "/api/v1/sessions/s1/activity")
require.Equal(t, http.StatusOK, w.Code)
var body db.SessionActivityResponse
require.NoError(t, json.NewDecoder(w.Body).Decode(&body))
assert.NotZero(t, body.TotalMessages, "expected non-zero total_messages")
assert.NotEmpty(t, body.Buckets, "expected non-empty buckets")
assert.Positive(t, body.IntervalSeconds, "expected positive interval_seconds")
}
func TestGetSessionActivity_NotFound(t *testing.T) {
te := setup(t)
w := te.get(t, "/api/v1/sessions/nonexistent/activity")
require.Equal(t, http.StatusOK, w.Code)
var body db.SessionActivityResponse
require.NoError(t, json.NewDecoder(w.Body).Decode(&body))
assert.Empty(t, body.Buckets, "expected empty buckets for nonexistent session")
}