Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xranx OpenContext Native Store Tests

From Leeroopedia
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

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

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment