mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-03 09:33:47 +01:00
test(repo-list): cover the stale resync and blocking before picker writes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
07bdae9252
commit
8524903a5b
2 files changed
+25
No files matched your search
@@ -797,6 +797,16 @@ describeMongo("GitHub App credential and repository integration", function () {
|
||||
expect((await Installations.findOne({ installationId: 4 })).blocked).to.equal(false);
|
||||
});
|
||||
|
||||
it("blocks a deleted installation even when the picker list update fails", async () => {
|
||||
const UserRepositories = require("../src/core/model/user-repositories").UserRepositoryModel;
|
||||
const original = UserRepositories.deleteMany;
|
||||
UserRepositories.deleteMany = async () => { throw new Error("picker write failed"); };
|
||||
try {
|
||||
expect((await webhook("installation", { action: "deleted", installation: { id: 4, app_id: 123 } })).status).to.equal(503);
|
||||
} finally { UserRepositories.deleteMany = original; }
|
||||
expect((await Installations.findOne({ installationId: 4 })).blocked).to.equal(true);
|
||||
});
|
||||
|
||||
it("does not let an in-flight installation check undo a deletion", async () => {
|
||||
await Installations.create({ appId: "123", installationId: 4, revision: "old", blocked: true, reconciliationPending: true });
|
||||
mock(async () => {
|
||||
|
||||
@@ -186,6 +186,21 @@ describeMongo("stored repository picker list", function () {
|
||||
expect(stored).to.have.length(250);
|
||||
});
|
||||
|
||||
it("resyncs a list older than 12 hours in the background", async () => {
|
||||
await setCredential(owner.id, "oauth-token");
|
||||
await picker();
|
||||
await list.settleRepositorySyncs();
|
||||
calls = [];
|
||||
await Syncs.updateOne({ ownerId: owner.id }, { $set: { syncedAt: new Date(Date.now() - 11 * 3600_000) } });
|
||||
await picker();
|
||||
await list.settleRepositorySyncs();
|
||||
expect(calls).to.deep.equal([]);
|
||||
await Syncs.updateOne({ ownerId: owner.id }, { $set: { syncedAt: new Date(Date.now() - 13 * 3600_000) } });
|
||||
expect((await picker()).status).to.equal(200);
|
||||
await list.settleRepositorySyncs();
|
||||
expect(calls).to.deep.equal([1, 2, 3]);
|
||||
});
|
||||
|
||||
it("pauses after a rate limit instead of retrying on every load", async () => {
|
||||
await setCredential(owner.id, "oauth-token");
|
||||
github.octokit = () => ({ request: async () => {
|
||||
|
||||
Reference in new issue
Block a user