test: add coverage for detect_source_type, format_stars_short, extract_entries, and last_commit_at parsing

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-03-23 02:25:44 +08:00
parent aa2e742c56
commit e71f38ef4e
2 changed files with 152 additions and 1 deletions

View File

@@ -135,6 +135,24 @@ class TestParseGraphqlResponse:
assert result["a/x"]["stars"] == 100
assert result["b/y"]["stars"] == 200
def test_extracts_last_commit_at(self):
data = {
"repo_0": {
"stargazerCount": 100,
"owner": {"login": "org"},
"defaultBranchRef": {"target": {"committedDate": "2025-06-01T00:00:00Z"}},
}
}
repos = ["org/repo"]
result = parse_graphql_response(data, repos)
assert result["org/repo"]["last_commit_at"] == "2025-06-01T00:00:00Z"
def test_missing_default_branch_ref(self):
data = {"repo_0": {"stargazerCount": 50, "owner": {"login": "org"}}}
repos = ["org/repo"]
result = parse_graphql_response(data, repos)
assert result["org/repo"]["last_commit_at"] == ""
class TestMainSkipsFreshCache:
"""Verify that main() skips fetching when all cache entries are fresh."""