Class: Fbe::Graph::Fake
- Inherits:
-
Object
- Object
- Fbe::Graph::Fake
- Defined in:
- lib/fbe/github_graph.rb
Overview
Fake GitHub GraphQL client for testing.
This class mocks the GraphQL client interface and returns predictable test data without making actual API calls. It’s used when the application is in testing mode.
Instance Method Summary collapse
-
#issue_type_event(node_id) ⇒ Hash?
Returns mock issue type event data.
- #pull_request_reviews(_owner, _name) ⇒ Object
- #pull_requests_with_reviews(_owner, _name, _since) ⇒ Object
-
#query(_query) ⇒ Hash
Executes a GraphQL query (mock implementation).
-
#resolved_conversations(owner, name, _number) ⇒ Array<Hash>
Returns mock resolved conversation threads.
-
#total_commits(owner = nil, name = nil, branch = nil, repos: nil) ⇒ Integer, Array<Hash>
Returns mock total commit count.
-
#total_issues_and_pulls(_owner, _name) ⇒ Hash
Returns mock issue and pull request counts.
Instance Method Details
#issue_type_event(node_id) ⇒ Hash?
Returns mock issue type event data.
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
# File 'lib/fbe/github_graph.rb', line 516 def issue_type_event(node_id) case node_id when 'ITAE_examplevq862Ga8lzwAAAAQZanzv' { 'type' => 'IssueTypeAddedEvent', 'created_at' => Time.parse('2025-05-11 18:17:16 UTC'), 'issue_type' => { 'id' => 'IT_exampleQls4BmRE0', 'name' => 'Bug', 'description' => 'An unexpected problem or behavior' }, 'prev_issue_type' => nil, 'actor' => { 'login' => 'yegor256', 'type' => 'User', 'id' => 526_301, 'name' => 'Yegor', 'email' => '[email protected]' } } when 'ITCE_examplevq862Ga8lzwAAAAQZbq9S' { 'type' => 'IssueTypeChangedEvent', 'created_at' => Time.parse('2025-05-11 20:23:13 UTC'), 'issue_type' => { 'id' => 'IT_kwDODJdQls4BmREz', 'name' => 'Task', 'description' => 'A specific piece of work' }, 'prev_issue_type' => { 'id' => 'IT_kwDODJdQls4BmRE0', 'name' => 'Bug', 'description' => 'An unexpected problem or behavior' }, 'actor' => { 'login' => 'yegor256', 'type' => 'User', 'id' => 526_301, 'name' => 'Yegor', 'email' => '[email protected]' } } when 'ITRE_examplevq862Ga8lzwAAAAQcqceV' { 'type' => 'IssueTypeRemovedEvent', 'created_at' => Time.parse('2025-05-11 22:09:42 UTC'), 'issue_type' => { 'id' => 'IT_kwDODJdQls4BmRE1', 'name' => 'Feature', 'description' => 'A request, idea, or new functionality' }, 'prev_issue_type' => nil, 'actor' => { 'login' => 'yegor256', 'type' => 'User', 'id' => 526_301, 'name' => 'Yegor', 'email' => '[email protected]' } } end end |
#pull_request_reviews(_owner, _name) ⇒ Object
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/fbe/github_graph.rb', line 591 def pull_request_reviews(_owner, _name, **) [ { 'id' => 'PR_kwDOL6J6Ss6iprCx', 'number' => 2, 'reviews' => [ { 'id' => 'PRR_kwDOL6J6Ss647NCl', 'submitted_at' => Time.parse('2025-10-02 12:58:42 UTC') }, { 'id' => 'PRR_kwDOL6J6Ss647NC8', 'submitted_at' => Time.parse('2025-10-02 15:58:42 UTC') } ], 'reviews_has_next_page' => false, 'reviews_next_cursor' => 'yc29yOnYyO1' }, { 'id' => 'PR_kwDOL6J6Ss6rhJ7T', 'number' => 5, 'reviews' => [{ 'id' => 'PRR_kwDOL6J6Ss64_mnn', 'submitted_at' => Time.parse('2025-10-03 15:58:42 UTC') }], 'reviews_has_next_page' => false, 'reviews_next_cursor' => 'yc29yOnYyO2' }, { 'id' => 'PR_kwDOL6J6Ss6r13fG', 'number' => 21, 'reviews' => [{ 'id' => 'PRR_kwDOL6J6Ss65AbIA', 'submitted_at' => Time.parse('2025-10-04 15:58:42 UTC') }], 'reviews_has_next_page' => false, 'reviews_next_cursor' => 'yc29yOnYyO3' } ] end |
#pull_requests_with_reviews(_owner, _name, _since) ⇒ Object
579 580 581 582 583 584 585 586 587 588 589 |
# File 'lib/fbe/github_graph.rb', line 579 def pull_requests_with_reviews(_owner, _name, _since, **) { 'pulls_with_reviews' => [ { 'id' => 'PR_kwDOL6J6Ss6iprCx', 'number' => 2 }, { 'id' => 'PR_kwDOL6J6Ss6rhJ7T', 'number' => 5 }, { 'id' => 'PR_kwDOL6J6Ss6r13fG', 'number' => 21 } ], 'has_next_page' => false, 'next_cursor' => 'Y3Vyc29yOnYyOpHOdh_xUw==' } end |
#query(_query) ⇒ Hash
Executes a GraphQL query (mock implementation).
446 447 448 |
# File 'lib/fbe/github_graph.rb', line 446 def query(_query) {} end |
#resolved_conversations(owner, name, _number) ⇒ Array<Hash>
Returns mock resolved conversation threads.
459 460 461 462 463 464 465 466 |
# File 'lib/fbe/github_graph.rb', line 459 def resolved_conversations(owner, name, _number) data = { zerocracy_baza: [ conversation('PRRT_kwDOK2_4A85BHZAR') ] } data[:"#{owner}_#{name}"] || [] end |
#total_commits(owner = nil, name = nil, branch = nil, repos: nil) ⇒ Integer, Array<Hash>
Returns mock total commit count.
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/fbe/github_graph.rb', line 490 def total_commits(owner = nil, name = nil, branch = nil, repos: nil) raise 'Need owner, name and branch or repos' if owner.nil? && name.nil? && branch.nil? && repos.nil? raise 'Owner, name and branch is required' if (owner.nil? || name.nil? || branch.nil?) && repos.nil? raise 'Repos list cannot be empty' if owner.nil? && name.nil? && branch.nil? && repos&.empty? raise 'Need only owner, name and branch or repos' if (!owner.nil? || !name.nil? || !branch.nil?) && !repos.nil? if owner && name && branch 1484 else repos.each_with_index.map do |(owner, name, branch), _i| { 'owner' => owner, 'name' => name, 'branch' => branch, 'total_commits' => 1484 } end end end |
#total_issues_and_pulls(_owner, _name) ⇒ Hash
Returns mock issue and pull request counts.
476 477 478 479 480 481 |
# File 'lib/fbe/github_graph.rb', line 476 def total_issues_and_pulls(_owner, _name) { 'issues' => 23, 'pulls' => 19 } end |