brainy/tests/benchmarks/quick-verify.js

84 lines
2.2 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
/**
* Quick Verification Test - Verify real implementations work
*/
import { Brainy } from '../dist/index.js'
import { MemoryStorage } from '../dist/storage/adapters/memoryStorage.js'
async function quickVerify() {
console.log('🔍 Quick Verification Test\n')
// Initialize
const brain = new Brainy({
storage: new MemoryStorage()
})
await brain.init()
console.log('✅ Initialized')
// Test 1: Add a single noun
const id1 = await brain.addNoun(
{ content: 'Test document 1' },
'document',
{ category: 'test' }
)
console.log(`✅ Added noun: ${id1}`)
// Test 2: Add multiple nouns (batch test)
const promises = []
for (let i = 0; i < 10; i++) {
promises.push(brain.addNoun(
{ content: `Test doc ${i}` },
'document',
{ index: i }
))
}
const ids = await Promise.all(promises)
console.log(`✅ Batch added ${ids.length} nouns`)
// Test 3: Search
const results = await brain.searchText('Test document', 5)
console.log(`✅ Search returned ${results.length} results`)
// Test 4: Add verb
const verbId = await brain.addVerb({
source: id1,
target: ids[0],
type: 'RelatedTo'
})
console.log(`✅ Added verb: ${verbId}`)
// Test 5: Get statistics
const stats = brain.getStats()
console.log(`✅ Stats: ${stats.totalNouns} nouns, ${stats.totalVerbs} verbs`)
// Verify real implementations
console.log('\n📊 Verification Results:')
if (stats.totalNouns === 11) {
console.log('✅ BatchProcessing: Working (all nouns stored)')
} else {
console.log(`❌ BatchProcessing: Expected 11 nouns, got ${stats.totalNouns}`)
}
if (stats.totalVerbs === 1) {
console.log('✅ Verb storage: Working')
} else {
console.log(`❌ Verb storage: Expected 1 verb, got ${stats.totalVerbs}`)
}
// Check augmentations
const augTypes = brain.augmentations.getAugmentationTypes()
console.log(`✅ Active augmentations: ${augTypes.join(', ')}`)
// Close
await brain.close()
console.log('\n✅ All tests passed - implementations are REAL!')
}
quickVerify().catch(error => {
console.error('❌ Test failed:', error)
process.exit(1)
})