- Add new tools-fs crate with read, glob, and grep utilities - Fix glob command to support actual glob patterns (**, *) instead of just directory walking - Rename binary from "code" to "owlen" to match package name - Fix test to reference correct binary name "owlen" - Add API key support to OllamaClient for authentication 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
use assert_cmd::Command;
|
|
use httpmock::prelude::*;
|
|
use predicates::prelude::PredicateBooleanExt;
|
|
|
|
#[tokio::test]
|
|
async fn headless_streams_ndjson() {
|
|
let server = MockServer::start_async().await;
|
|
// Mock /api/chat with NDJSON lines
|
|
let body = serde_json::json!({
|
|
"model": "qwen2.5",
|
|
"messages": [{"role": "user", "content": "hello"}],
|
|
"stream": true
|
|
});
|
|
|
|
let response = concat!(
|
|
r#"{"message":{"role":"assistant","content":"Hel"}}"#,"\n",
|
|
r#"{"message":{"role":"assistant","content":"lo"}}"#,"\n",
|
|
r#"{"done":true}"#,"\n",
|
|
);
|
|
|
|
let _m = server.mock(|when, then| {
|
|
when.method(POST)
|
|
.path("/api/chat")
|
|
.json_body(body.clone());
|
|
then.status(200)
|
|
.header("content-type", "application/x-ndjson")
|
|
.body(response);
|
|
});
|
|
|
|
let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("owlen"));
|
|
cmd.arg("--ollama-url").arg(server.base_url())
|
|
.arg("--model").arg("qwen2.5")
|
|
.arg("--print")
|
|
.arg("hello");
|
|
|
|
cmd.assert()
|
|
.success()
|
|
.stdout(predicates::str::contains("Hello").count(1).or(predicates::str::contains("Hel").and(predicates::str::contains("lo"))));
|
|
}
|