Files
kebab/crates/kebab-llm-local/tests/construction.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

38 lines
1.4 KiB
Rust

//! Construction-time tests — verify `OllamaLanguageModel::new` reads the
//! relevant config fields and exposes them via the trait surface, all
//! without touching the network (per design §7.2 lazy-connect contract).
use kebab_config::Config;
use kebab_llm_local::{LanguageModel, OllamaLanguageModel};
#[test]
fn construction_with_default_config_returns_expected_model_ref() {
let cfg = Config::defaults();
let llm = OllamaLanguageModel::new(&cfg).expect("construction should not hit network");
let m = llm.model_ref();
assert_eq!(m.provider, "ollama");
// Default model id from kb-config §6.4 — pinned here so a silent
// default flip in kb-config is caught by this test.
assert_eq!(m.id, cfg.models.llm.model);
// Chat models have no embedding dimension (§3.8).
assert_eq!(m.dimensions, None);
}
#[test]
fn context_tokens_returns_config_value() {
let mut cfg = Config::defaults();
cfg.models.llm.context_tokens = 16384;
let llm = OllamaLanguageModel::new(&cfg).unwrap();
assert_eq!(llm.context_tokens(), 16384);
}
#[test]
fn construction_does_not_require_a_running_ollama() {
// Point the endpoint at a closed port. Construction must succeed —
// the contract is "lazy connect on first generate_stream call".
let mut cfg = Config::defaults();
cfg.models.llm.endpoint = "http://127.0.0.1:1".to_string();
let _llm = OllamaLanguageModel::new(&cfg).expect("new() must not hit the network");
}