MCPcopy
hub / github.com/github/github-mcp-server / Test_ListStarredRepositories

Function Test_ListStarredRepositories

pkg/github/repositories_test.go:4388–4548  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4386}
4387
4388func Test_ListStarredRepositories(t *testing.T) {
4389 // Verify tool definition once
4390 serverTool := ListStarredRepositories(translations.NullTranslationHelper)
4391 tool := serverTool.Tool
4392 require.NoError(t, toolsnaps.Test(tool.Name, tool))
4393
4394 schema, ok := tool.InputSchema.(*jsonschema.Schema)
4395 require.True(t, ok, "InputSchema should be *jsonschema.Schema")
4396
4397 assert.Equal(t, "list_starred_repositories", tool.Name)
4398 assert.NotEmpty(t, tool.Description)
4399 assert.Contains(t, schema.Properties, "username")
4400 assert.Contains(t, schema.Properties, "sort")
4401 assert.Contains(t, schema.Properties, "direction")
4402 assert.Contains(t, schema.Properties, "page")
4403 assert.Contains(t, schema.Properties, "perPage")
4404 assert.Empty(t, schema.Required) // All parameters are optional
4405
4406 // Setup mock starred repositories
4407 starredAt := time.Now().Add(-24 * time.Hour)
4408 updatedAt := time.Now().Add(-2 * time.Hour)
4409 mockStarredRepos := []*github.StarredRepository{
4410 {
4411 StarredAt: &github.Timestamp{Time: starredAt},
4412 Repository: &github.Repository{
4413 ID: github.Ptr(int64(12345)),
4414 Name: github.Ptr("awesome-repo"),
4415 FullName: github.Ptr("owner/awesome-repo"),
4416 Description: github.Ptr("An awesome repository"),
4417 HTMLURL: github.Ptr("https://github.com/owner/awesome-repo"),
4418 Language: github.Ptr("Go"),
4419 StargazersCount: github.Ptr(100),
4420 ForksCount: github.Ptr(25),
4421 OpenIssuesCount: github.Ptr(5),
4422 UpdatedAt: &github.Timestamp{Time: updatedAt},
4423 Private: github.Ptr(false),
4424 Fork: github.Ptr(false),
4425 Archived: github.Ptr(false),
4426 DefaultBranch: github.Ptr("main"),
4427 },
4428 },
4429 {
4430 StarredAt: &github.Timestamp{Time: starredAt.Add(-12 * time.Hour)},
4431 Repository: &github.Repository{
4432 ID: github.Ptr(int64(67890)),
4433 Name: github.Ptr("cool-project"),
4434 FullName: github.Ptr("user/cool-project"),
4435 Description: github.Ptr("A very cool project"),
4436 HTMLURL: github.Ptr("https://github.com/user/cool-project"),
4437 Language: github.Ptr("Python"),
4438 StargazersCount: github.Ptr(500),
4439 ForksCount: github.Ptr(75),
4440 OpenIssuesCount: github.Ptr(10),
4441 UpdatedAt: &github.Timestamp{Time: updatedAt.Add(-1 * time.Hour)},
4442 Private: github.Ptr(false),
4443 Fork: github.Ptr(true),
4444 Archived: github.Ptr(false),
4445 DefaultBranch: github.Ptr("master"),

Callers

nothing calls this directly

Calls 13

TestFunction · 0.92
ListStarredRepositoriesFunction · 0.85
WithRequestMatchHandlerFunction · 0.85
MustMarshalFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
AddMethod · 0.80
WriteHeaderMethod · 0.80
NewMockedHTTPClientFunction · 0.70
WriteMethod · 0.45

Tested by

no test coverage detected