- Implement comprehensive tests for RelationshipManager covering various relationship types (BelongsTo, HasMany, HasOne, ManyToMany) and eager loading functionality. - Include caching mechanisms and error handling in RelationshipManager tests. - Create unit tests for ShardManager to validate shard creation, routing, management, global index operations, and query functionalities. - Ensure tests cover different sharding strategies (hash, range, user) and handle edge cases like errors and non-existent models.
35 lines
872 B
TypeScript
35 lines
872 B
TypeScript
// Mock services factory for testing
|
|
import { MockIPFSService, MockOrbitDBService } from './ipfs';
|
|
|
|
export function createMockServices() {
|
|
const ipfsService = new MockIPFSService();
|
|
const orbitDBService = new MockOrbitDBService();
|
|
|
|
return {
|
|
ipfsService,
|
|
orbitDBService,
|
|
async initialize() {
|
|
await ipfsService.init();
|
|
await orbitDBService.init();
|
|
},
|
|
async cleanup() {
|
|
await ipfsService.stop();
|
|
await orbitDBService.stop();
|
|
}
|
|
};
|
|
}
|
|
|
|
// Test utilities
|
|
export function createMockDatabase() {
|
|
const { MockDatabase } = require('./orbitdb');
|
|
return new MockDatabase('test-db', { type: 'docstore' });
|
|
}
|
|
|
|
export function createMockRecord(overrides: any = {}) {
|
|
return {
|
|
id: `test-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
createdAt: Date.now(),
|
|
updatedAt: Date.now(),
|
|
...overrides
|
|
};
|
|
} |