mirror of
https://github.com/lukaszraczylo/claude-mnemonic.git
synced 2026-06-05 23:03:55 +00:00
7a061c85eb
* refactor(hooks): simplify hook execution with shared context - [x] Extract BaseInput struct to eliminate duplicate fields across hooks - [x] Create RunHook handler pattern for session-start and user-prompt - [x] Create RunStatuslineHook for fast statusline rendering without worker startup - [x] Add HookContext struct to pass port, project, CWD, SessionID to handlers - [x] Add db/interface.go with ObservationReader/Writer interfaces - [x] Add comprehensive conflict management tests in sqlite/conflict_test.go - [x] Add vector client tests for Count, ModelVersion, NeedsRebuild, GetStaleVectors - [x] Add FilterByThreshold helper tests for query result filtering - [x] Make handlers_test more robust for network-dependent update checks - [x] Update package versions in UI * Move to GORM + general cleanup * feat(mcp): add observation relations discovery and scoring integration - [x] Add find_related_observations MCP tool for discovering related observations by confidence - [x] Integrate scoring calculator and recalculator into MCP server initialization - [x] Add pattern, relation, and session stores to MCP server dependencies - [x] Register MCP server in Claude Code settings during plugin installation - [x] Update install scripts (bash, PowerShell) to configure MCP server settings - [x] Switch plugin manifest files to template-based versioning (plugin.json.tpl, marketplace.json.tpl) - [x] Update all MCP server tests to pass new dependency parameters
71 lines
1.5 KiB
Go
71 lines
1.5 KiB
Go
package worker
|
|
|
|
import (
|
|
"database/sql"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/lukaszraczylo/claude-mnemonic/internal/db/gorm"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
// testStore creates a gorm.Store with a temporary database for testing.
|
|
// Uses gorm.NewStore which runs migrations (requires FTS5).
|
|
// Skips the test if FTS5 is not available.
|
|
func testStore(t *testing.T) (*gorm.Store, func()) {
|
|
t.Helper()
|
|
|
|
// First check if FTS5 is available
|
|
if !hasFTS5ForTest(t) {
|
|
t.Skip("FTS5 not available in this SQLite build")
|
|
}
|
|
|
|
tmpDir, err := os.MkdirTemp("", "claude-mnemonic-test-*")
|
|
if err != nil {
|
|
t.Fatalf("create temp dir: %v", err)
|
|
}
|
|
|
|
dbPath := tmpDir + "/test.db"
|
|
|
|
store, err := gorm.NewStore(gorm.Config{
|
|
Path: dbPath,
|
|
MaxConns: 1,
|
|
})
|
|
if err != nil {
|
|
_ = os.RemoveAll(tmpDir)
|
|
t.Fatalf("create store: %v", err)
|
|
}
|
|
|
|
cleanup := func() {
|
|
_ = store.Close()
|
|
_ = os.RemoveAll(tmpDir)
|
|
}
|
|
|
|
return store, cleanup
|
|
}
|
|
|
|
// hasFTS5ForTest checks if FTS5 is available in the SQLite build.
|
|
func hasFTS5ForTest(t *testing.T) bool {
|
|
t.Helper()
|
|
|
|
tmpDir, err := os.MkdirTemp("", "fts5-check-*")
|
|
if err != nil {
|
|
return false
|
|
}
|
|
defer func() { _ = os.RemoveAll(tmpDir) }()
|
|
|
|
dbPath := tmpDir + "/check.db"
|
|
db, err := sql.Open("sqlite3", dbPath)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
defer func() { _ = db.Close() }()
|
|
|
|
_, err = db.Exec("CREATE VIRTUAL TABLE IF NOT EXISTS fts5_test USING fts5(content)")
|
|
if err != nil {
|
|
return false
|
|
}
|
|
_, _ = db.Exec("DROP TABLE IF EXISTS fts5_test")
|
|
return true
|
|
}
|