diff options
| author | Christian Cleberg <[email protected]> | 2026-04-11 14:13:19 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-11 14:13:19 -0500 |
| commit | 9d88cda2826224aab5cda15424453ea1cad75ae0 (patch) | |
| tree | 0b9d2e5d9d692ce7f56708035219f6caee97bd8a /tests/test_ingestion.py | |
| parent | 6149ca9c394df7d316f80db05ad0fc2aea6c550d (diff) | |
| download | hutch-stats-9d88cda2826224aab5cda15424453ea1cad75ae0.tar.gz hutch-stats-9d88cda2826224aab5cda15424453ea1cad75ae0.tar.bz2 hutch-stats-9d88cda2826224aab5cda15424453ea1cad75ae0.zip | |
feat: auto-discover git repositories for actor polling
Diffstat (limited to 'tests/test_ingestion.py')
| -rw-r--r-- | tests/test_ingestion.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/test_ingestion.py b/tests/test_ingestion.py index 788ec81..3b7db16 100644 --- a/tests/test_ingestion.py +++ b/tests/test_ingestion.py @@ -310,6 +310,67 @@ def test_git_ingestion_normalizes_commit_aliases_and_repository_names(db_session assert tracked_repositories == ["~ccleberg/Hutch"] +def test_git_ingestion_auto_discovers_owned_repositories(db_session) -> None: + settings = make_settings( + ACTOR_ALIASES_JSON={"~ccleberg": ["[email protected]", "Chris Cleberg"]}, + GIT_TRACKED_REPOSITORIES=[], + ) + client = StubClient( + payloads_by_query={ + "query UserRepositories": { + "user": { + "repositories": { + "results": [ + {"name": "Hutch", "owner": {"canonicalName": "~ccleberg"}}, + ], + "cursor": None, + } + } + }, + "query RepositoryLog": { + "user": { + "repository": { + "name": "Hutch", + "owner": {"canonicalName": "~ccleberg"}, + "log": { + "results": [ + { + "id": "abc123", + "shortId": "abc123", + "author": { + "name": "Chris Cleberg", + "email": "[email protected]", + "time": "2026-03-30T12:00:00Z", + }, + "committer": { + "name": "Chris Cleberg", + "email": "[email protected]", + "time": "2026-03-30T12:00:00Z", + }, + "message": "Auto-discovered repo commit", + } + ], + "cursor": None, + }, + } + } + }, + } + ) + + todo_service = TodoIngestionService( + StubClient(payload={"me": {"canonicalName": "~ccleberg"}, "events": {"results": [], "cursor": None}}), + settings, + ) + git_service = GitIngestionService(client, settings) + poller = PollerService(todo_service=todo_service, git_service=git_service) + + inserted = poller.poll_all(db_session, "~ccleberg") + + assert inserted == 1 + assert any("query UserRepositories" in call[0] for call in client.calls) + + def test_sync_overlap_reuses_cursor_window_and_suppresses_duplicates(db_session) -> None: event = NormalizedEvent( service="todo", |
