- Archive migration script to scripts/archive/migrate-to-couchdb.js - Update error handler middleware for CouchDB-appropriate errors - Fix MongoDB references in test utilities and comments - Replace MongoDB ObjectId references with CouchDB ID patterns - Preserve existing functionality while removing legacy dependencies 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
41 lines
843 B
JavaScript
41 lines
843 B
JavaScript
/**
|
|
* Utility functions for generating test IDs
|
|
* Replaces legacy ID generation functionality
|
|
*/
|
|
|
|
/**
|
|
* Generate a random test ID string
|
|
* Format: random alphanumeric string (24 characters)
|
|
*/
|
|
function generateTestId() {
|
|
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
let result = '';
|
|
for (let i = 0; i < 24; i++) {
|
|
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate a test ID with a specific prefix
|
|
*/
|
|
function generateTestIdWithPrefix(prefix) {
|
|
return `${prefix}_${generateTestId()}`;
|
|
}
|
|
|
|
/**
|
|
* Generate multiple unique test IDs
|
|
*/
|
|
function generateTestIds(count) {
|
|
const ids = [];
|
|
for (let i = 0; i < count; i++) {
|
|
ids.push(generateTestId());
|
|
}
|
|
return ids;
|
|
}
|
|
|
|
module.exports = {
|
|
generateTestId,
|
|
generateTestIdWithPrefix,
|
|
generateTestIds,
|
|
}; |