Files
kebab/crates/kebab-store-sqlite/tests/common/mod.rs
altair823 911fb49550 refactor(rename): kb crates → kebab — Cargo packages, folders, Rust modules
프로젝트 이름 `kb` → `kebab` rename 의 첫 단계.

- workspace `Cargo.toml`: members `crates/kb-*` → `crates/kebab-*`,
  repository URL `altair823/kb` → `altair823/kebab`.
- 18 crate 폴더 rename via `git mv` (history 보존).
- 각 crate `Cargo.toml`: `name = "kb-*"` → `"kebab-*"`, path deps
  `../kb-*` → `../kebab-*`.
- 모든 `.rs`: `kb_<id>` snake-case 모듈 path 18 개 (`kb_core`,
  `kb_config`, `kb_app`, `kb_cli`, `kb_eval`, `kb_search`, `kb_chunk`,
  `kb_normalize`, `kb_source_fs`, `kb_parse_md`, `kb_parse_types`,
  `kb_store_sqlite`, `kb_store_vector`, `kb_embed`, `kb_embed_local`,
  `kb_llm`, `kb_llm_local`, `kb_rag`) → `kebab_<id>` 일괄 sed (단어
  경계 \\b 사용해 영어 문장 안의 "kb" 약어 미오염).

CLI binary 이름 (`[[bin]] name = "kb"`), 환경변수 `KB_*`, XDG paths,
tracing target, 그리고 docs sweep 은 다음 commit 에서.

## 검증

- `cargo check --workspace` clean — 모든 crate 빌드 통과 후 commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 03:28:08 +00:00

51 lines
1.5 KiB
Rust

//! Shared test scaffolding: temp data_dir + freshly opened SqliteStore.
#![allow(dead_code)]
use std::path::PathBuf;
use kebab_config::Config;
use rusqlite::Connection;
use tempfile::TempDir;
pub struct TestEnv {
pub temp: TempDir,
pub config: Config,
}
impl TestEnv {
pub fn new() -> Self {
Self::with_threshold(100)
}
/// Override the copy-threshold (useful for the reference-mode test
/// where we want a small file to land on the reference branch).
pub fn with_threshold(copy_threshold_mb: u64) -> Self {
let temp = tempfile::tempdir().expect("tempdir");
let mut config = Config::defaults();
config.storage.data_dir = temp.path().to_string_lossy().into_owned();
config.storage.copy_threshold_mb = copy_threshold_mb;
Self { temp, config }
}
pub fn config(&self) -> Config {
self.config.clone()
}
pub fn data_dir(&self) -> PathBuf {
self.temp.path().to_path_buf()
}
pub fn db_path(&self) -> PathBuf {
self.temp.path().join("kb.sqlite")
}
/// Open a side-channel rusqlite connection for direct SQL inspection.
/// The store-owned connection is held inside a Mutex; opening a fresh
/// one is the simplest way for tests to peek at row counts / pragmas.
pub fn with_conn<T>(&self, f: impl FnOnce(&Connection) -> rusqlite::Result<T>) -> T {
let conn = Connection::open(self.db_path()).expect("open side conn");
f(&conn).expect("with_conn closure")
}
}