Skip to content

Commit

Permalink
Merge pull request #48 from Yegorov/156
Browse files Browse the repository at this point in the history
judjes-action#156: add pull requests to Fbe::FakeOctokit#search_issues
  • Loading branch information
yegor256 authored Jul 31, 2024
2 parents cd3234c + 70f3f16 commit 0fa4602
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 13 deletions.
57 changes: 44 additions & 13 deletions lib/fbe/octo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,50 @@ def create_commit_comment(_repo, sha, text)
}
end

def search_issues(_query, _options = {})
{
items: [
{
number: 42,
labels: [
{
name: 'bug'
}
]
}
]
}
def search_issues(query, _options = {})
if query.include?('type:pr') && query.include?('is:unmerged')
{
total_count: 1,
incomplete_results: false,
items: [
{
id: 42,
number: 10,
title: 'Awesome PR 10'
}
]
}
elsif query.include?('type:pr')
{
total_count: 2,
incomplete_results: false,
items: [
{
id: 42,
number: 10,
title: 'Awesome PR 10'
},
{
id: 43,
number: 11,
title: 'Awesome PR 11'
}
]
}
else
{
items: [
{
number: 42,
labels: [
{
name: 'bug'
}
]
}
]
}
end
end

def commits_since(repo, _since)
Expand Down
12 changes: 12 additions & 0 deletions test/fbe/test_octo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ def test_commit_pulls
assert_equal(0, o.commit_pulls('zerocracy/fbe', '16b3ea6b71c6e932ba7666c40ca846ecaa6d6f0d').size)
end

def test_search_issues
WebMock.disable_net_connect!
o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new({ 'testing' => true }))
assert_equal(42, o.search_issues('repo:zerocracy/fbe type:issue').dig(:items, 0, :number))
total_pr_count = 2
assert_equal(total_pr_count, o.search_issues('repo:zerocracy/fbe type:pr')[:total_count])
assert_equal(total_pr_count, o.search_issues('repo:zerocracy/fbe type:pr')[:items].count)
unmereged_pr_count = 1
assert_equal(unmereged_pr_count, o.search_issues('repo:zerocracy/fbe type:pr is:unmerged')[:total_count])
assert_equal(unmereged_pr_count, o.search_issues('repo:zerocracy/fbe type:pr is:unmerged')[:items].count)
end

def test_pauses_when_quota_is_exceeded
WebMock.disable_net_connect!
global = {}
Expand Down

0 comments on commit 0fa4602

Please sign in to comment.