mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
fix(launch): back off build retries on GitHub limits, dedupe fetcher misses, no ad hoc render before first build
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -215,3 +215,30 @@ def test_data_miss_rate_limited_returns_503(client, monkeypatch):
|
||||
assert r.status_code == 503
|
||||
assert r.get_json() == {"error": "github_rate_limited"}
|
||||
assert dbmod.get_user("alice") is None
|
||||
|
||||
|
||||
def test_concurrent_data_misses_fetch_once(client, monkeypatch):
|
||||
# Concurrent misses for one user used to each run a full GitHub fetch;
|
||||
# the per-user lock makes later callers read what the first stored.
|
||||
import threading, time as _time
|
||||
calls = []
|
||||
|
||||
def fake_fetch(username, **_kw):
|
||||
calls.append(username)
|
||||
_time.sleep(0.3)
|
||||
return {"user": {"login": username}, "repos": [], "events": []}
|
||||
monkeypatch.setattr(apimod.github, "fetch_github_data", fake_fetch)
|
||||
monkeypatch.setattr(apimod, "_is_github_not_found", lambda _d: False)
|
||||
app = apimod.app
|
||||
codes = []
|
||||
|
||||
def hit():
|
||||
with app.test_client() as c:
|
||||
codes.append(c.get("/data/alice", headers={"X-Internal-Token": "secret"}).status_code)
|
||||
threads = [threading.Thread(target=hit) for _ in range(3)]
|
||||
for t in threads:
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
assert codes == [200, 200, 200]
|
||||
assert calls == ["alice"]
|
||||
|
||||
Reference in New Issue
Block a user