두 번째 commit. 사용자 facing surface (CLI binary, env vars, XDG paths) + 코드 안 single-letter token (`KB_`, `kb.sqlite`, `/kb/`, tracing target) 일괄 rename. 그리고 3 개 file rename: - 디자인 doc `2026-04-27-kb-final-form-design.md` → `2026-04-27-kebab-final-form-design.md` - 최초 보고서 `kb_local_rust_report.md` → `kebab_local_rust_report.md` - workspace ignore `.kbignore` → `.kebabignore` ## 변경 - `crates/kebab-cli/Cargo.toml`: `[[bin]] name = "kb"` → `"kebab"`. - `crates/kebab-cli/src/main.rs`: `#[command(name = "kb", …)]` → `name = "kebab"`. - 모든 `KB_*` env var (코드 + doc + 테스트) → `KEBAB_*`. apply_env prefix 매칭 + 30+ 개 setting 키 모두. - XDG paths: `~/.config/kb` / `~/.local/share/kb` / `~/.cache/kb` / `~/.local/state/kb` → `~/.config/kebab` 등. config defaults + expand_path tests + paths.rs 의 hardcode 모두. - SQLite filename: `kb.sqlite` → `kebab.sqlite` (`SQLITE_FILE` const + 테스트 hardcode 모두). - tracing target: `target: "kb-*"` → `"kebab-*"` (10+ 곳). - snapshot fixture: `.kbignore` → `.kebabignore` (`fixtures/source-fs/ tree-1.snapshot.json` 갱신). ## 검증 - `cargo test --workspace -j 1` clean (linker OOM 회피 위해 직렬). - `cargo clippy --workspace --all-targets -- -D warnings` clean. 다음 commit 에서 docs sweep. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
1.5 KiB
Rust
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("kebab.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")
|
|
}
|
|
}
|