Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing cast to hash in repo discovery script #212

Merged
merged 8 commits into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions steps/discover-repos.rb
Expand Up @@ -75,10 +75,11 @@
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
puts(json)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@howcanunot this is a debug output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch..
yeap, I'll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done
thanks!

json[:items].each do |i|
found[i[:full_name]] = {
full_name: i[:full_name],
Expand All @@ -102,7 +103,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"