Files
kebab/crates/kebab-embed/tests/reexports.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

62 lines
1.9 KiB
Rust

//! Compile-only test: verifies the crate's public surface (trait re-exports
//! and the `assert_vector_shape` helper) is reachable without the `mock`
//! feature.
//!
//! Runs under both `cargo test -p kb-embed` and
//! `cargo test -p kb-embed --features mock`.
use kebab_embed::{
Embedder, EmbeddingInput, EmbeddingKind, EmbeddingModelId, EmbeddingVersion,
assert_vector_shape,
};
/// A trivial in-test impl that does NOT rely on the `mock` feature — proves
/// the trait surface alone is enough to write an `Embedder`.
struct ZeroEmbedder {
dims: usize,
}
impl Embedder for ZeroEmbedder {
fn model_id(&self) -> EmbeddingModelId {
EmbeddingModelId("zero".into())
}
fn model_version(&self) -> EmbeddingVersion {
EmbeddingVersion("0".into())
}
fn dimensions(&self) -> usize {
self.dims
}
fn embed(&self, inputs: &[EmbeddingInput<'_>]) -> anyhow::Result<Vec<Vec<f32>>> {
Ok(inputs.iter().map(|_| vec![0.0; self.dims]).collect())
}
}
#[test]
fn reexports_compile_without_mock_feature() {
let e: Box<dyn Embedder> = Box::new(ZeroEmbedder { dims: 4 });
let inputs = [
EmbeddingInput {
text: "hello",
kind: EmbeddingKind::Document,
},
EmbeddingInput {
text: "world",
kind: EmbeddingKind::Query,
},
];
let v = e.embed(&inputs).expect("zero embed");
assert_eq!(v.len(), 2);
assert_vector_shape(&v, 4);
}
/// Sanity: when built WITHOUT `--features mock`, the `MockEmbedder` symbol
/// is absent. We can't usefully test `nm` from inside a unit test, but we
/// can at least confirm the cfg gate parses both ways. See PR notes for the
/// CI-side `nm`/`cargo bloat` symbol scan.
#[cfg(not(feature = "mock"))]
#[test]
fn mock_feature_off_compiles() {
// No-op — the test's existence proves the `not(feature = "mock")` gate
// compiles and the crate is usable without `MockEmbedder`.
}