mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-10 13:36:45 +03:00
fix: add config-encryption mocks to test files for CI compatibility
- Add config-encryption module mocks to gitea-enhanced.test.ts - Add config-encryption module mocks to gitea-starred-repos.test.ts - Update helpers mock in setup.bun.ts to include createEvent function The CI environment was loading modules in a different order than local, causing the config-encryption module to be accessed before it was mocked in the global setup. Adding the mocks directly to the test files ensures they are available regardless of module loading order.
This commit is contained in:
@@ -25,6 +25,14 @@ mock.module("@/lib/db", () => ({
|
||||
repositories: {}
|
||||
}));
|
||||
|
||||
// Mock config encryption
|
||||
mock.module("@/lib/utils/config-encryption", () => ({
|
||||
decryptConfigTokens: (config: any) => config,
|
||||
encryptConfigTokens: (config: any) => config,
|
||||
getDecryptedGitHubToken: (config: any) => config.githubConfig?.token || "",
|
||||
getDecryptedGiteaToken: (config: any) => config.giteaConfig?.token || ""
|
||||
}));
|
||||
|
||||
// Now import the modules we're testing
|
||||
import {
|
||||
getGiteaRepoInfo,
|
||||
|
||||
@@ -31,6 +31,14 @@ mock.module("@/lib/db", () => {
|
||||
};
|
||||
});
|
||||
|
||||
// Mock config encryption
|
||||
mock.module("@/lib/utils/config-encryption", () => ({
|
||||
decryptConfigTokens: (config: any) => config,
|
||||
encryptConfigTokens: (config: any) => config,
|
||||
getDecryptedGitHubToken: (config: any) => config.githubConfig?.token || "",
|
||||
getDecryptedGiteaToken: (config: any) => config.giteaConfig?.token || ""
|
||||
}));
|
||||
|
||||
describe("Starred Repository Error Handling", () => {
|
||||
let originalFetch: typeof global.fetch;
|
||||
let consoleLogs: string[] = [];
|
||||
|
||||
@@ -97,8 +97,12 @@ mock.module("@/lib/utils/config-encryption", () => {
|
||||
|
||||
// Mock the helpers module to prevent database operations
|
||||
mock.module("@/lib/helpers", () => {
|
||||
const mockCreateMirrorJob = mock(() => Promise.resolve("mock-job-id"));
|
||||
const mockCreateEvent = mock(() => Promise.resolve());
|
||||
|
||||
return {
|
||||
createMirrorJob: mock(() => Promise.resolve("mock-job-id")),
|
||||
createMirrorJob: mockCreateMirrorJob,
|
||||
createEvent: mockCreateEvent,
|
||||
// Add other helpers as needed
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user