mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-25 06:56:45 +00:00
Merge pull request #3096 from ultraworkers/fix-160-session-store-lifecycle
fix(#160): add regression test for SessionStore lifecycle
This commit is contained in:
@@ -640,14 +640,7 @@ pub fn model_token_limit(model: &str) -> Option<ModelTokenLimit> {
|
||||
max_output_tokens: 16_384,
|
||||
context_window_tokens: 256_000,
|
||||
}),
|
||||
// Hotfix: Unknown models get conservative defaults to avoid crashes.
|
||||
// Uses the minimum of known supported models: max_output_tokens: 16_384,
|
||||
// context_window_tokens: 131_072. This may under-utilize the model's
|
||||
// actual capabilities but hopefully ensures safer operation.
|
||||
_ => Some(ModelTokenLimit {
|
||||
max_output_tokens: 16_384,
|
||||
context_window_tokens: 131_072,
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1857,6 +1857,7 @@ mod tests {
|
||||
delta: super::ChunkDelta {
|
||||
content: None,
|
||||
reasoning_content: Some("think".to_string()),
|
||||
thinking: None,
|
||||
tool_calls: Vec::new(),
|
||||
},
|
||||
finish_reason: None,
|
||||
@@ -1873,6 +1874,7 @@ mod tests {
|
||||
delta: super::ChunkDelta {
|
||||
content: Some(" answer".to_string()),
|
||||
reasoning_content: None,
|
||||
thinking: None,
|
||||
tool_calls: Vec::new(),
|
||||
},
|
||||
finish_reason: Some("stop".to_string()),
|
||||
|
||||
@@ -82,7 +82,7 @@ async fn send_message_posts_json_and_parses_response() {
|
||||
);
|
||||
assert_eq!(
|
||||
request.headers.get("user-agent").map(String::as_str),
|
||||
Some("claude-code/0.1.0")
|
||||
Some("claude-code/0.1.3")
|
||||
);
|
||||
assert_eq!(
|
||||
request.headers.get("anthropic-beta").map(String::as_str),
|
||||
|
||||
@@ -1230,4 +1230,44 @@ mod tests {
|
||||
);
|
||||
fs::remove_dir_all(base).expect("temp dir should clean up");
|
||||
}
|
||||
|
||||
/// #160 regression: store-level list_sessions/session_exists/delete_session
|
||||
/// lifecycle works end-to-end.
|
||||
#[test]
|
||||
fn session_store_lifecycle_regression_160() {
|
||||
// given
|
||||
let base = temp_dir();
|
||||
fs::create_dir_all(&base).expect("base dir should exist");
|
||||
let store = SessionStore::from_cwd(&base).expect("store should build");
|
||||
let session = persist_session_via_store(&store, "160 regression test");
|
||||
|
||||
// when/then — session exists and is listed before deletion
|
||||
assert!(
|
||||
!store.list_sessions().expect("list").is_empty(),
|
||||
"store should have at least one session"
|
||||
);
|
||||
assert!(
|
||||
store.session_exists(&session.session_id),
|
||||
"session should exist before deletion"
|
||||
);
|
||||
|
||||
// when — delete the session
|
||||
let deleted = store
|
||||
.delete_session(&session.session_id)
|
||||
.expect("delete should succeed");
|
||||
|
||||
// then — session is gone
|
||||
assert_eq!(deleted.id, session.session_id);
|
||||
assert!(!deleted.path.exists(), "session file should be removed");
|
||||
assert!(
|
||||
!store.session_exists(&session.session_id),
|
||||
"session should not exist after deletion"
|
||||
);
|
||||
assert!(
|
||||
store.list_sessions().expect("list").is_empty(),
|
||||
"store should have no sessions after deletion"
|
||||
);
|
||||
|
||||
fs::remove_dir_all(base).expect("temp dir should clean up");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user