Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-10-19 19:36:19 +03:00
parent 170a44c377
commit 5f7bffd6e4
17 changed files with 454 additions and 85 deletions

View File

@@ -14,7 +14,7 @@ test("Импорт: не больше двух разборов сразу, ли
active--;
});
const running = [task(), task(), task()];
await assert.rejects(task(), (e) => e.status === 429 && e.message === "Занято");
await assert.rejects(task(), (e) => e.status === 429 && e.code === "busy" && e.message === "Занято");
// Each finished task hands its slot to the one waiting.
while (release.length) {
release.shift()();
@@ -47,6 +47,10 @@ test("Импорт: лимит запросов считается по адре
};
assert.ok(call("10.0.0.1").passed);
assert.ok(call("10.0.0.1").passed);
assert.deepEqual(call("10.0.0.1"), { status: 429, body: { error: "Подождите" }, passed: false });
assert.deepEqual(call("10.0.0.1"), {
status: 429,
body: { error: "Подождите", code: "too_many_requests" },
passed: false,
});
assert.ok(call("10.0.0.2").passed);
});