MCPcopy
hub / github.com/cli/cli / TestListLatestSessionsForViewer

Function TestListLatestSessionsForViewer

pkg/cmd/agent-task/capi/sessions_test.go:17–1186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestListLatestSessionsForViewer(t *testing.T) {
18 sampleDateString := "2025-08-29T00:00:00Z"
19 sampleDate, err := time.Parse(time.RFC3339, sampleDateString)
20 require.NoError(t, err)
21
22 tests := []struct {
23 name string
24 perPage int
25 limit int
26 httpStubs func(*testing.T, *httpmock.Registry)
27 wantErr string
28 wantOut []*Session
29 }{
30 {
31 name: "zero limit",
32 limit: 0,
33 wantOut: nil,
34 },
35 {
36 name: "no sessions",
37 limit: 10,
38 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
39 reg.Register(
40 httpmock.WithHost(
41 httpmock.QueryMatcher("GET", "agents/sessions", url.Values{
42 "page_number": {"1"},
43 "page_size": {"50"},
44 }),
45 "api.githubcopilot.com",
46 ),
47 httpmock.StringResponse(`{"sessions":[]}`),
48 )
49 },
50 wantOut: nil,
51 },
52 {
53 name: "single session",
54 limit: 10,
55 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
56 reg.Register(
57 httpmock.WithHost(
58 httpmock.QueryMatcher("GET", "agents/sessions", url.Values{
59 "page_number": {"1"},
60 "page_size": {"50"},
61 }),
62 "api.githubcopilot.com",
63 ),
64 httpmock.StringResponse(heredoc.Docf(`
65 {
66 "sessions": [
67 {
68 "id": "sess1",
69 "name": "Build artifacts",
70 "user_id": 1,
71 "agent_id": 2,
72 "logs": "",
73 "state": "completed",
74 "owner_id": 10,

Callers

nothing calls this directly

Calls 12

RegisterMethod · 0.95
VerifyMethod · 0.95
WithHostFunction · 0.92
QueryMatcherFunction · 0.92
StringResponseFunction · 0.92
GraphQLFunction · 0.92
GraphQLQueryFunction · 0.92
StatusStringResponseFunction · 0.92
NewCAPIClientFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected