mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-08 20:46:44 +03:00
- Updated GitHub Actions workflow to use Bun's test runner and coverage reporting. - Added comprehensive testing documentation for the Gitea Mirror project. - Refactored test scripts in package.json to align with Bun's testing commands. - Created new test files for database, Gitea, GitHub, health, and mirroring APIs. - Implemented mock functions for API tests to handle various scenarios and responses. - Established a test setup file for consistent test environment configuration.
43 lines
979 B
TypeScript
43 lines
979 B
TypeScript
import { describe, test, expect, mock, beforeAll, afterAll } from "bun:test";
|
|
import { drizzle } from "drizzle-orm/bun-sqlite";
|
|
|
|
// Silence console logs during tests
|
|
let originalConsoleLog: typeof console.log;
|
|
|
|
beforeAll(() => {
|
|
// Save original console.log
|
|
originalConsoleLog = console.log;
|
|
// Replace with no-op function
|
|
console.log = () => {};
|
|
});
|
|
|
|
afterAll(() => {
|
|
// Restore original console.log
|
|
console.log = originalConsoleLog;
|
|
});
|
|
|
|
// Mock the database module
|
|
mock.module("bun:sqlite", () => {
|
|
return {
|
|
Database: mock(function() {
|
|
return {
|
|
query: mock(() => ({
|
|
all: mock(() => []),
|
|
run: mock(() => ({}))
|
|
}))
|
|
};
|
|
})
|
|
};
|
|
});
|
|
|
|
// Mock the database tables
|
|
describe("Database Schema", () => {
|
|
test("database connection can be created", async () => {
|
|
// Import the db from the module
|
|
const { db } = await import("./index");
|
|
|
|
// Check that db is defined
|
|
expect(db).toBeDefined();
|
|
});
|
|
});
|