Untested POC

This commit is contained in:
Alex Selimov 2025-10-05 20:23:47 -04:00
parent 461318a656
commit bfb9b61194
Signed by: aselimov
GPG key ID: 3DDB9C3E023F1F31
5 changed files with 254 additions and 0 deletions

View file

@ -19,6 +19,29 @@ A relational document system for Neovim that brings Notion-like database capabil
### Installation
Using [lazy.nvim](https://github.com/folke/lazy.nvim) (recommended):
```lua
{
'your-username/notex.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons'
},
config = function()
require('notex').setup({
-- Configuration options
database_path = vim.fn.stdpath('data') .. '/notex/notex.db',
auto_index = true,
performance = {
enable_caching = true,
cache_size = 100
}
})
end
}
```
Using [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua

31
minimal_init.lua Normal file
View file

@ -0,0 +1,31 @@
-- Minimal Neovim config for testing
vim.opt.runtimepath:prepend('.')
-- Mock vim functions that tests need
vim.loop = vim.loop or {}
vim.loop.fs_stat = vim.loop.fs_stat or function(path)
return {type = "file", size = 100}
end
vim.loop.timer_start = vim.loop.timer_start or function(delay, callback)
return 1
end
vim.loop.timer_stop = vim.loop.timer_stop or function(timer_id)
-- Mock timer stop
end
vim.uv = vim.uv or {}
vim.uv.new_timer = vim.uv.new_timer or function()
return {
start = function() end,
stop = function() end,
close = function() end
}
end
vim.uv.hrtime = vim.uv.hrtime or function()
return os.clock() * 1e9
end
vim.schedule = vim.schedule or function(fn) fn() end
vim.defer_fn = vim.defer_fn or function(fn, delay) fn() end
print("Minimal Neovim config loaded")

81
run_tests.lua Normal file
View file

@ -0,0 +1,81 @@
-- Set up Lua path
package.path = "./lua/?.lua;./lua/?/init.lua;" .. package.path
-- Extend existing vim global
if not _G.vim then _G.vim = {} end
local vim = _G.vim
-- Mock missing vim functions if they don't exist
vim.fn = vim.fn or {}
vim.fn.stdpath = vim.fn.stdpath or function(type)
return "/tmp/notex_test"
end
vim.fn.getpid = vim.fn.getpid or function()
return 12345
end
vim.loop = vim.loop or {}
vim.loop.fs_stat = vim.loop.fs_stat or function(path)
return {type = "file", size = 100}
end
vim.loop.timer_start = vim.loop.timer_start or function(delay, callback)
return 1
end
vim.loop.timer_stop = vim.loop.timer_stop or function(timer_id)
-- Mock timer stop
end
vim.uv = vim.uv or {}
vim.uv.new_timer = vim.uv.new_timer or function()
return {
start = function() end,
stop = function() end,
close = function() end
}
end
vim.uv.hrtime = vim.uv.hrtime or function()
return os.clock() * 1e9
end
vim.trim = vim.trim or function(str)
return str:match("^%s*(.-)%s*$")
end
vim.split = vim.split or function(str, sep)
local fields = {}
local pattern = string.format("([^%s]+)", sep)
str:gsub(pattern, function(c) fields[#fields + 1] = c end)
return fields
end
vim.tbl_contains = vim.tbl_contains or function(t, val)
for _, v in ipairs(t) do
if v == val then return true end
end
return false
end
-- Add missing API functions
vim.api = vim.api or {}
vim.api.nvim_buf_get_lines = vim.api.nvim_buf_get_lines or function() return {} end
vim.api.nvim_buf_set_lines = vim.api.nvim_buf_set_lines or function() end
vim.api.nvim_create_buf = vim.api.nvim_create_buf or function() return 1 end
vim.g = vim.g or {}
vim.b = vim.b or {}
vim.o = vim.o or {}
vim.bo = vim.bo or {}
vim.wo = vim.wo or {}
-- Mock scheduler
vim.schedule = vim.schedule or function(fn) fn() end
vim.defer_fn = vim.defer_fn or function(fn, delay) fn() end
-- Run busted with command line args
local busted = require('busted')
local args = arg or {}
if #args == 0 then
args = {'tests/', '--verbose'}
end
busted.run(args)

60
test_runner.lua Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
exec nvim --headless "$0" "$@"
-- Set up Lua path
package.path = "./lua/?.lua;./lua/?/init.lua;" .. package.path
-- Mock minimal vim global for testing
_G.vim = {
fn = {
stdpath = function(type)
return "/tmp/notex_test"
end,
getpid = function()
return 12345
end,
},
loop = {
fs_stat = function(path)
-- Mock file stat
return {type = "file", size = 100}
end,
timer_start = function(delay, callback)
return 1 -- mock timer id
end,
timer_stop = function(timer_id)
-- Mock timer stop
end,
},
uv = {
new_timer = function()
return {
start = function() end,
stop = function() end,
close = function() end
}
end,
hrtime = function()
return os.clock() * 1e9
end,
},
trim = function(str)
return str:match("^%s*(.-)%s*$")
end,
split = function(str, sep)
local fields = {}
local pattern = string.format("([^%s]+)", sep)
str:gsub(pattern, function(c) fields[#fields + 1] = c end)
return fields
end,
tbl_contains = function(t, val)
for _, v in ipairs(t) do
if v == val then return true end
end
return false
end,
}
-- Run busted with command line args
local busted = require('busted')
busted.run(arg)

59
test_runner.sh Executable file
View file

@ -0,0 +1,59 @@
#!/bin/bash
# Run tests with Neovim context
LUA_PATH="./lua/?.lua;./lua/?/init.lua;$LUA_PATH" nvim --headless -c "
-- Mock minimal vim global for testing
_G.vim = {
fn = {
stdpath = function(type)
return '/tmp/notex_test'
end,
getpid = function()
return 12345
end,
},
loop = {
fs_stat = function(path)
return {type = 'file', size = 100}
end,
timer_start = function(delay, callback)
return 1
end,
timer_stop = function(timer_id)
-- Mock timer stop
end,
},
uv = {
new_timer = function()
return {
start = function() end,
stop = function() end,
close = function() end
}
end,
hrtime = function()
return os.clock() * 1e9
end,
},
trim = function(str)
return str:match('^%s*(.-)%s*$')
end,
split = function(str, sep)
local fields = {}
local pattern = string.format('([^%s]+)', sep)
str:gsub(pattern, function(c) fields[#fields + 1] = c end)
return fields
end,
tbl_contains = function(t, val)
for _, v in ipairs(t) do
if v == val then return true end
end
return false
end,
}
-- Run busted
local busted = require('busted')
local args = {'$@'}
busted.run(args)
" -c "qa"