Implementation:0xranx OpenContext Native Store Tests
| Knowledge Sources | |
|---|---|
| Domains | Testing, Native_Bindings |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Test suite for the NAPI-RS native store bindings, validating folder CRUD, document CRUD, metadata, and manifest operations through the Node.js interface.
Description
The test-store.js file in crates/opencontext-node/ uses node --test to test the native store bindings exported from index.js. Tests are organized into describe blocks: initEnvironment, folder operations (createFolder, renameFolder, moveFolder, removeFolder), document operations (createDoc, saveDocContent, getDocContent, getDocMeta, getDocByStableId, moveDoc, renameDoc, removeDoc, setDocDescription), and generateManifest. Each test uses environment variables to point to a temp directory.
Usage
Run with node --test test-store.js in the crates/opencontext-node directory after building the native module.
Code Reference
Source Location
- Repository: 0xranx_OpenContext
- File: crates/opencontext-node/test-store.js
- Lines: 1-418
Signature
const { describe, it, before, after, beforeEach } = require('node:test');
const assert = require('node:assert');
describe('Native Store Bindings', () => { ... })
function setupTestEnv() // Sets OPENCONTEXT_ROOT, OPENCONTEXT_CONTEXTS_ROOT, OPENCONTEXT_DB_PATH
function cleanupTestEnv() // Restores env vars and removes temp dir
Import
// Run directly: node --test test-store.js
// Requires built native module: npm run build
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| native | object | Yes | Loaded NAPI bindings from index.js |
| env vars | string | Yes | OPENCONTEXT_ROOT, OPENCONTEXT_CONTEXTS_ROOT, OPENCONTEXT_DB_PATH |
Usage Examples
Running Tests
cd crates/opencontext-node
npm run build # Build the native module first
node --test test-store.js