Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Mar 20, 2024
2 parents 90a7fd1 + 4ebcb9e commit 09ca599
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions steps/discover-repos.rb
Expand Up @@ -75,7 +75,7 @@
break
end
json = if opts[:dry]
{ items: page > 100 ? [] : [{ full_name: "foo/#{Random.hex(5)}", created_at: Time.now }] }
{ items: page > 100 ? [] : Array.new(size) { { full_name: "foo/#{Random.hex(5)}", created_at: Time.now } } }
else
github.search_repositories(query, per_page: size, page: page)
end
Expand All @@ -102,7 +102,7 @@
puts "Found #{found.count} total repositories in GitHub"

if found.count > opts[:total]
found = found.first(opts[:total])
found = found.first(opts[:total]).to_h
puts "We will use only the first #{opts[:total]} repositories"
end

Expand Down
16 changes: 14 additions & 2 deletions tests/steps/test-discover-repos.sh
Expand Up @@ -30,12 +30,24 @@ tex=${TARGET}/foo.tex

{
rm -f "${csv}"
msg=$("${LOCAL}/steps/discover-repos.rb" --dry --pause=0 --total=3 --min-stars=100 --max-stars=1000 "--csv=${csv}" "--tex=${tex}")
msg=$("${LOCAL}/steps/discover-repos.rb" --dry --pause=0 --total=3 --page-size=1 --min-stars=100 --max-stars=1000 "--csv=${csv}" "--tex=${tex}")
echo "${msg}"
echo "${msg}" | grep "Found 1 repositories in page #0"
echo "${msg}" | grep "Found 3 total repositories in GitHub"
test -e "${csv}"
test -s "${tex}"
test "$(wc -l < "${csv}" | xargs)" = '4'
} > "${stdout}" 2>&1
echo "👍🏻 A few repositories discovered correctly"
echo "👍🏻 Small repositories discovery test is succeed"

{
rm -f "${csv}"
msg=$("${LOCAL}/steps/discover-repos.rb" --dry --pause=0 --total=35 --page-size=30 --min-stars=100 --max-stars=1000 "--csv=${csv}" "--tex=${tex}")
echo "${msg}"
echo "${msg}" | grep "Found 60 total repositories in GitHub"
echo "${msg}" | grep "We will use only the first 35 repositories"
test -e "${csv}"
test -s "${tex}"
test "$(wc -l < "${csv}" | xargs)" = '36'
} > "${stdout}" 2>&1
echo "👍🏻 Medium repositories discovery test is succeed"

0 comments on commit 09ca599

Please sign in to comment.