class Fbe::Graph::Fake

# => 1484 (always returns the same value)
result = fake.total_commits(‘owner’, ‘repo’, ‘main’)
fake = Fbe::Graph::Fake.new
@example Using the fake client in tests
is in testing mode.
test data without making actual API calls. It’s used when the application
This class mocks the GraphQL client interface and returns predictable
Fake GitHub GraphQL client for testing.

def conversation(id)

Returns:
  • (Hash) - Mock conversation data with comments

Parameters:
  • id (String) -- The conversation thread ID
def conversation(id)
  {
    'id' => id,
    'isResolved' => true,
    'comments' => {
      'nodes' => [
        {
          'id' => 'PRRC_kwDOK2_4A85l3obO',
          'body' => 'first message',
          'author' => { '__typename' => 'User', 'login' => 'reviewer' },
          'createdAt' => '2024-08-08T09:41:46Z'
        },
        {
          'id' => 'PRRC_kwDOK2_4A85l3yTp',
          'body' => 'second message',
          'author' => { '__typename' => 'User', 'login' => 'programmer' },
          'createdAt' => '2024-08-08T10:01:55Z'
        }
      ]
    }
  }
end

def issue_type_event(node_id)

Returns:
  • (Hash, nil) - Event data for known IDs, nil otherwise

Parameters:
  • node_id (String) -- The event node ID
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

def query(_query)

Returns:
  • (Hash) - Empty hash

Parameters:
  • _query (String) -- The GraphQL query (ignored)
def query(_query)
  {}
end

def resolved_conversations(owner, name, _number)

Returns:
  • (Array) - Array of conversation threads

Parameters:
  • _number (Integer) -- Pull request number (ignored)
  • name (String) -- Repository name
  • owner (String) -- Repository owner
def resolved_conversations(owner, name, _number)
  data = {
    zerocracy_baza: [
      conversation('PRRT_kwDOK2_4A85BHZAR')
    ]
  }
  data[:"#{owner}_#{name}"] || []
end

def total_commits(_owner, _name, _branch)

Returns:
  • (Integer) - Always returns 1484

Parameters:
  • _branch (String) -- Branch name (ignored)
  • _name (String) -- Repository name (ignored)
  • _owner (String) -- Repository owner (ignored)
def total_commits(_owner, _name, _branch)
  1484
end

def total_issues_and_pulls(_owner, _name)

Returns:
  • (Hash) - Hash with 'issues' and 'pulls' counts

Parameters:
  • _name (String) -- Repository name (ignored)
  • _owner (String) -- Repository owner (ignored)
def total_issues_and_pulls(_owner, _name)
  {
    'issues' => 23,
    'pulls' => 19
  }
end