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_commits_pushed(_owner, _name, _since) ⇒ Object
-
#total_issues_and_pulls(_owner, _name) ⇒ Hash
Returns mock issue and pull request counts.
- #total_issues_created(_owner, _name, _since) ⇒ Object
- #total_releases_published(_owner, _name, _since) ⇒ Object
Instance Method Details
#issue_type_event(node_id) ⇒ Hash?
Returns mock issue type event data.
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
# File 'lib/fbe/github_graph.rb', line 647 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' => 'example@gmail.com' } } 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' => 'example@gmail.com' } } 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' => 'example@gmail.com' } } end end |
#pull_request_reviews(_owner, _name) ⇒ Object
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
# File 'lib/fbe/github_graph.rb', line 722 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
710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/fbe/github_graph.rb', line 710 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).
579 580 581 |
# File 'lib/fbe/github_graph.rb', line 579 def query(_query) {} end |
#resolved_conversations(owner, name, _number) ⇒ Array<Hash>
Returns mock resolved conversation threads.
592 593 594 595 |
# File 'lib/fbe/github_graph.rb', line 592 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.
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/fbe/github_graph.rb', line 619 def total_commits(owner = nil, name = nil, branch = nil, repos: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity raise(Fbe::Error, 'Need owner, name and branch or repos') if owner.nil? && name.nil? && branch.nil? && repos.nil? raise(Fbe::Error, 'Owner, name and branch is required') if (owner.nil? || name.nil? || branch.nil?) && repos.nil? raise(Fbe::Error, 'Repos list cannot be empty') if owner.nil? && name.nil? && branch.nil? && repos&.empty? if (!owner.nil? || !name.nil? || !branch.nil?) && !repos.nil? raise(Fbe::Error, 'Need only owner, name and branch or repos') end 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_commits_pushed(_owner, _name, _since) ⇒ Object
751 752 753 754 755 756 |
# File 'lib/fbe/github_graph.rb', line 751 def total_commits_pushed(_owner, _name, _since) { 'commits' => 29, 'hoc' => 1857 } end |
#total_issues_and_pulls(_owner, _name) ⇒ Hash
Returns mock issue and pull request counts.
605 606 607 608 609 610 |
# File 'lib/fbe/github_graph.rb', line 605 def total_issues_and_pulls(_owner, _name) { 'issues' => 23, 'pulls' => 19 } end |
#total_issues_created(_owner, _name, _since) ⇒ Object
758 759 760 761 762 763 |
# File 'lib/fbe/github_graph.rb', line 758 def total_issues_created(_owner, _name, _since) { 'issues' => 17, 'pulls' => 8 } end |
#total_releases_published(_owner, _name, _since) ⇒ Object
765 766 767 |
# File 'lib/fbe/github_graph.rb', line 765 def total_releases_published(_owner, _name, _since) { 'releases' => 7 } end |