(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func 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, |
nothing calls this directly
no test coverage detected