(t *testing.T)
| 494 | } |
| 495 | |
| 496 | func Test_GetDiscussion(t *testing.T) { |
| 497 | // Verify tool definition and schema |
| 498 | toolDef := GetDiscussion(translations.NullTranslationHelper) |
| 499 | tool := toolDef.Tool |
| 500 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 501 | |
| 502 | assert.Equal(t, "get_discussion", tool.Name) |
| 503 | assert.NotEmpty(t, tool.Description) |
| 504 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 505 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 506 | assert.Contains(t, schema.Properties, "owner") |
| 507 | assert.Contains(t, schema.Properties, "repo") |
| 508 | assert.Contains(t, schema.Properties, "discussionNumber") |
| 509 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "discussionNumber"}) |
| 510 | |
| 511 | // Use exact string query that matches implementation output |
| 512 | qGetDiscussion := "query($discussionNumber:Int!$owner:String!$repo:String!){repository(owner: $owner, name: $repo){discussion(number: $discussionNumber){number,title,body,createdAt,closed,isAnswered,answerChosenAt,url,category{name}}}}" |
| 513 | |
| 514 | vars := map[string]any{ |
| 515 | "owner": "owner", |
| 516 | "repo": "repo", |
| 517 | "discussionNumber": float64(1), |
| 518 | } |
| 519 | tests := []struct { |
| 520 | name string |
| 521 | response githubv4mock.GQLResponse |
| 522 | expectError bool |
| 523 | expected map[string]any |
| 524 | errContains string |
| 525 | }{ |
| 526 | { |
| 527 | name: "successful retrieval", |
| 528 | response: githubv4mock.DataResponse(map[string]any{ |
| 529 | "repository": map[string]any{"discussion": map[string]any{ |
| 530 | "number": 1, |
| 531 | "title": "Test Discussion Title", |
| 532 | "body": "This is a test discussion", |
| 533 | "url": "https://github.com/owner/repo/discussions/1", |
| 534 | "createdAt": "2025-04-25T12:00:00Z", |
| 535 | "closed": false, |
| 536 | "isAnswered": false, |
| 537 | "category": map[string]any{"name": "General"}, |
| 538 | }}, |
| 539 | }), |
| 540 | expectError: false, |
| 541 | expected: map[string]any{ |
| 542 | "number": float64(1), |
| 543 | "title": "Test Discussion Title", |
| 544 | "body": "This is a test discussion", |
| 545 | "url": "https://github.com/owner/repo/discussions/1", |
| 546 | "closed": false, |
| 547 | "isAnswered": false, |
| 548 | }, |
| 549 | }, |
| 550 | { |
| 551 | name: "discussion not found", |
| 552 | response: githubv4mock.ErrorResponse("discussion not found"), |
| 553 | expectError: true, |
nothing calls this directly
no test coverage detected