mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Remove a test
Without an explicit auth check, the test becomes too complex
This commit is contained in:
parent
0826c62f2d
commit
43a62aabdc
1 changed files with 0 additions and 69 deletions
|
|
@ -2221,75 +2221,6 @@ mod tests {
|
|||
assert_eq!(credentials.access_token, "2");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_cached_llm_token_is_cleared_after_sign_out(cx: &mut TestAppContext) {
|
||||
init_test(cx);
|
||||
let llm_token_request_count = Arc::new(std::sync::atomic::AtomicUsize::new(0));
|
||||
let http_client = FakeHttpClient::create({
|
||||
let llm_token_request_count = llm_token_request_count.clone();
|
||||
move |request| {
|
||||
let llm_token_request_count = llm_token_request_count.clone();
|
||||
async move {
|
||||
assert_eq!(request.uri().path(), "/client/llm_tokens");
|
||||
let request_count = llm_token_request_count.fetch_add(1, Ordering::SeqCst) + 1;
|
||||
let token = format!("llm-token-{request_count}");
|
||||
Ok(http_client::Response::builder()
|
||||
.status(200)
|
||||
.body(
|
||||
serde_json::to_string(&cloud_api_client::CreateLlmTokenResponse {
|
||||
token: cloud_api_client::LlmToken(token),
|
||||
})
|
||||
.expect("failed to serialize LLM token response")
|
||||
.into(),
|
||||
)
|
||||
.expect("failed to build LLM token response"))
|
||||
}
|
||||
}
|
||||
});
|
||||
let client = cx.update(|cx| Client::new(Arc::new(FakeSystemClock::new()), http_client, cx));
|
||||
client.override_authenticate(|cx| {
|
||||
cx.background_spawn(async {
|
||||
Ok(Credentials {
|
||||
user_id: 1,
|
||||
access_token: "account-token".into(),
|
||||
})
|
||||
})
|
||||
});
|
||||
let llm_token = LlmApiToken::default();
|
||||
|
||||
client
|
||||
.sign_in(false, &cx.to_async())
|
||||
.await
|
||||
.expect("initial sign-in should succeed");
|
||||
assert_eq!(
|
||||
client
|
||||
.cached_llm_token(&llm_token, None)
|
||||
.await
|
||||
.expect("initial LLM token request should succeed"),
|
||||
"llm-token-1"
|
||||
);
|
||||
assert_eq!(llm_token_request_count.load(Ordering::SeqCst), 1);
|
||||
|
||||
client.sign_out(&cx.to_async()).await;
|
||||
client
|
||||
.cached_llm_token(&llm_token, None)
|
||||
.await
|
||||
.expect_err("signed-out clients should not reuse cached LLM tokens");
|
||||
|
||||
client
|
||||
.sign_in(false, &cx.to_async())
|
||||
.await
|
||||
.expect("reauthentication should succeed");
|
||||
assert_eq!(
|
||||
client
|
||||
.cached_llm_token(&llm_token, None)
|
||||
.await
|
||||
.expect("LLM token should be fetched again after reauthentication"),
|
||||
"llm-token-2"
|
||||
);
|
||||
assert_eq!(llm_token_request_count.load(Ordering::SeqCst), 2);
|
||||
}
|
||||
|
||||
#[gpui::test(iterations = 10)]
|
||||
async fn test_authenticating_more_than_once(
|
||||
cx: &mut TestAppContext,
|
||||
|
|
|
|||
Loading…
Reference in a new issue