mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-09 21:16:48 +03:00
fix: resolve CI test failures and timeouts
- Update Bun version in CI to match local version (1.2.16) - Add bunfig.toml with 5s test timeout to prevent hanging tests - Mock setTimeout globally in test setup to avoid timing issues - Add NODE_ENV check to skip delays during tests - Fix missing exports in config-encryption mock - Remove retryDelay in tests to ensure immediate execution These changes ensure tests run consistently between local and CI environments
This commit is contained in:
@@ -38,27 +38,17 @@ import { repoStatusEnum } from "@/types/Repository";
|
||||
|
||||
describe("Enhanced Gitea Operations", () => {
|
||||
let originalFetch: typeof global.fetch;
|
||||
let originalTimeout: typeof global.setTimeout;
|
||||
|
||||
beforeEach(() => {
|
||||
originalFetch = global.fetch;
|
||||
originalTimeout = global.setTimeout;
|
||||
// Clear mocks
|
||||
mockCreateMirrorJob.mockClear();
|
||||
mockDb.insert.mockClear();
|
||||
mockDb.update.mockClear();
|
||||
|
||||
// Mock setTimeout for consistent timing in tests
|
||||
global.setTimeout = ((fn: Function, delay: number) => {
|
||||
// Execute immediately in tests to avoid timing issues
|
||||
fn();
|
||||
return 0;
|
||||
}) as any;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
global.fetch = originalFetch;
|
||||
global.setTimeout = originalTimeout;
|
||||
});
|
||||
|
||||
describe("getGiteaRepoInfo", () => {
|
||||
@@ -196,7 +186,7 @@ describe("Enhanced Gitea Operations", () => {
|
||||
orgName: "starred",
|
||||
config,
|
||||
maxRetries: 3,
|
||||
retryDelay: 10,
|
||||
retryDelay: 0, // No delay in tests
|
||||
});
|
||||
|
||||
expect(orgId).toBe(999);
|
||||
@@ -248,6 +238,7 @@ describe("Enhanced Gitea Operations", () => {
|
||||
const orgId = await getOrCreateGiteaOrgEnhanced({
|
||||
orgName: "neworg",
|
||||
config,
|
||||
retryDelay: 0, // No delay in tests
|
||||
});
|
||||
|
||||
expect(orgId).toBe(777);
|
||||
|
||||
Reference in New Issue
Block a user