forge
Explore
Log in

Don't you dare go Hollow

Merged tests drop needless borrows and name their complex types

Browse files at this commit

5852a685c1c8a567f1940e21d10d046f2de1e63dAhmet Kaan GümüşParent: b757c23
  • lint
    • merged tests drop needless borrows and name their complex types
Show full message
🚨 lint: merged tests drop needless borrows and name their complex types
crates/forge-web/src/api/statuses.rsmodified+2 -1
@@ -361,7 +361,8 @@ mod tests {
361361 let bad_sha = report_uri("abc123");
362362 let missing = report_uri(&"0".repeat(40));
363363 // (case, uri, auth, cookie, body, expected status, expects a JSON error body)
364- let cases: [(&str, &str, Option<&str>, Option<&str>, Option<&str>, u16, bool); 10] = [
364+ type Case<'a> = (&'a str, &'a str, Option<&'a str>, Option<&'a str>, Option<&'a str>, u16, bool);
365+ let cases: [Case<'_>; 10] = [
365366 ("read-only token", report.as_str(), Some(reader.as_str()), None, Some(SUCCESS), 403, true),
366367 ("anonymous", report.as_str(), None, None, Some(SUCCESS), 401, true),
367368 ("bad token", report.as_str(), Some("Bearer forge_not_a_real_token"), None, Some(SUCCESS), 401, false),
crates/forge-web/src/git_auth.rsmodified+2 -1
@@ -102,7 +102,8 @@ mod tests {
102102 fn parse_basic_auth_cases() {
103103 // One labelled table: each case keeps its own input and expected result.
104104 let t = BASE64_STANDARD.encode("tahinli:t");
105- let cases: Vec<(&str, String, Option<(&str, &str)>)> = vec![
105+ type Case<'a> = (&'a str, String, Option<(&'a str, &'a str)>);
106+ let cases: Vec<Case<'_>> = vec![
106107 (
107108 "user and token",
108109 basic("tahinli:forge_abc"),
crates/forge-web/src/pages/browse_tests.rsmodified+13 -13
@@ -73,7 +73,7 @@ fn whitespace_commit(fx: &Fixture) -> String {
7373
7474 /// The commit toolbar, and the whitespace toggle that hides whitespace-only files.
7575 async fn scenario_whitespace_toolbar(fx: &Fixture) {
76- let oid = whitespace_commit(&fx);
76+ let oid = whitespace_commit(fx);
7777 let base = format!("/{OWNER}/{REPO}/commit/{oid}");
7878
7979 let (status, _, body) = get(&fx.router, &base).await;
@@ -275,7 +275,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
275275 );
276276 let page = format!("/{OWNER}/{REPO}/branches");
277277
278- let (status, _, html) = send(&fx.router, "GET", &page, Some(&cookie), &[]).await;
278+ let (status, _, html) = send(&fx.router, "GET", &page, Some(cookie), &[]).await;
279279 assert_eq!(status, 200);
280280 // feature is 1 ahead of and 54 behind main (the root is its base, main has 54 more commits).
281281 assert!(html.contains("1 ahead, 54 behind"), "{html}");
@@ -292,7 +292,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
292292 &fx.router,
293293 "POST",
294294 &page,
295- Some(&cookie),
295+ Some(cookie),
296296 &[("csrf", CSRF), ("name", "topic/one"), ("from", "feature")],
297297 )
298298 .await;
@@ -314,7 +314,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
314314 &fx.router,
315315 "POST",
316316 &page,
317- Some(&cookie),
317+ Some(cookie),
318318 &[("csrf", CSRF), ("name", name), ("from", from)],
319319 )
320320 .await;
@@ -338,7 +338,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
338338 &fx.router,
339339 "POST",
340340 &page,
341- Some(&cookie),
341+ Some(cookie),
342342 &[("csrf", "wrong"), ("name", "x"), ("from", "main")],
343343 )
344344 .await;
@@ -350,7 +350,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
350350 &fx.router,
351351 "POST",
352352 &delete,
353- Some(&cookie),
353+ Some(cookie),
354354 &[("csrf", CSRF), ("name", "topic/one"), ("oid", &fx.root)],
355355 )
356356 .await;
@@ -360,7 +360,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
360360 &fx.router,
361361 "POST",
362362 &delete,
363- Some(&cookie),
363+ Some(cookie),
364364 &[("csrf", CSRF), ("name", "topic/one"), ("oid", &feature_tip)],
365365 )
366366 .await;
@@ -374,7 +374,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) {
374374 &fx.router,
375375 "POST",
376376 &delete,
377- Some(&cookie),
377+ Some(cookie),
378378 &[("csrf", CSRF), ("name", "main"), ("oid", &main_tip)],
379379 )
380380 .await;
@@ -402,7 +402,7 @@ async fn scenario_protection(fx: &Fixture, cookie: &str) {
402402 &fx.router,
403403 "POST",
404404 &delete,
405- Some(&cookie),
405+ Some(cookie),
406406 &[("csrf", CSRF), ("name", "release/1"), ("oid", &tip)],
407407 )
408408 .await;
@@ -412,7 +412,7 @@ async fn scenario_protection(fx: &Fixture, cookie: &str) {
412412 &fx.router,
413413 "POST",
414414 &delete,
415- Some(&cookie),
415+ Some(cookie),
416416 &[("csrf", CSRF), ("name", "scratch"), ("oid", &tip)],
417417 )
418418 .await;
@@ -428,7 +428,7 @@ async fn scenario_default_branch(fx: &Fixture, cookie: &str) {
428428 &fx.router,
429429 "POST",
430430 &settings,
431- Some(&cookie),
431+ Some(cookie),
432432 &[
433433 ("csrf", CSRF),
434434 ("description", "demo"),
@@ -452,7 +452,7 @@ async fn scenario_default_branch(fx: &Fixture, cookie: &str) {
452452 &fx.router,
453453 "POST",
454454 &settings,
455- Some(&cookie),
455+ Some(cookie),
456456 &[
457457 ("csrf", CSRF),
458458 ("description", "demo"),
@@ -474,7 +474,7 @@ async fn scenario_default_branch(fx: &Fixture, cookie: &str) {
474474 &fx.router,
475475 "GET",
476476 &format!("/{OWNER}/{REPO}/settings"),
477- Some(&cookie),
477+ Some(cookie),
478478 &[],
479479 )
480480 .await;
crates/forge-web/src/pages/forgot.rsmodified+12 -12
@@ -291,10 +291,10 @@ mod tests {
291291 .await
292292 .unwrap();
293293 for address in ["nobody@example.com", "frank@example.com"] {
294- let (cookie, precsrf) = precsrf_for(&router, "/forgot").await;
294+ let (cookie, precsrf) = precsrf_for(router, "/forgot").await;
295295 let form = format!("precsrf={precsrf}&email={}", address.replace('@', "%40"));
296296 let (status, _, html) =
297- send(&router, "POST", "/forgot", Some(&cookie), Some(&form)).await;
297+ send(router, "POST", "/forgot", Some(&cookie), Some(&form)).await;
298298 assert_eq!(status, 200, "{address}");
299299 assert!(html.contains("a reset link is on its way"), "{address}");
300300 }
@@ -326,21 +326,21 @@ mod tests {
326326 .is_some()
327327 );
328328
329- let (cookie, precsrf) = precsrf_for(&router, "/forgot").await;
329+ let (cookie, precsrf) = precsrf_for(router, "/forgot").await;
330330 let form = format!("precsrf={precsrf}&email=gina%40example.com");
331- let (status, _, _) = send(&router, "POST", "/forgot", Some(&cookie), Some(&form)).await;
331+ let (status, _, _) = send(router, "POST", "/forgot", Some(&cookie), Some(&form)).await;
332332 assert_eq!(status, 200);
333- let body = wait_for_mail(&state, "/reset/").await;
333+ let body = wait_for_mail(state, "/reset/").await;
334334 let path = link_in(&body, "/reset/");
335335
336- let (status, _, html) = send(&router, "GET", &path, None, None).await;
336+ let (status, _, html) = send(router, "GET", &path, None, None).await;
337337 assert_eq!(status, 200);
338338 assert!(html.contains("Set a new password"));
339339
340- let (cookie, precsrf) = precsrf_for(&router, &path).await;
340+ let (cookie, precsrf) = precsrf_for(router, &path).await;
341341 let form =
342342 format!("precsrf={precsrf}&password=brand-new-password-1&confirm=brand-new-password-1");
343- let (status, _, html) = send(&router, "POST", &path, Some(&cookie), Some(&form)).await;
343+ let (status, _, html) = send(router, "POST", &path, Some(&cookie), Some(&form)).await;
344344 assert_eq!(status, 200);
345345 assert!(html.contains("Your password is changed"));
346346
@@ -352,10 +352,10 @@ mod tests {
352352 );
353353
354354 // The same link is spent now.
355- let (cookie, precsrf) = precsrf_for(&router, &path).await;
355+ let (cookie, precsrf) = precsrf_for(router, &path).await;
356356 let form =
357357 format!("precsrf={precsrf}&password=another-password-22&confirm=another-password-22");
358- let (status, _, html) = send(&router, "POST", &path, Some(&cookie), Some(&form)).await;
358+ let (status, _, html) = send(router, "POST", &path, Some(&cookie), Some(&form)).await;
359359 assert_eq!(status, 200);
360360 assert!(html.contains("This reset link is invalid"));
361361 }
@@ -376,9 +376,9 @@ mod tests {
376376 let token = state.store.create_reset_token(&user.id).await.unwrap();
377377 let path = format!("/reset/{token}");
378378
379- let (cookie, precsrf) = precsrf_for(&router, &path).await;
379+ let (cookie, precsrf) = precsrf_for(router, &path).await;
380380 let form = format!("precsrf={precsrf}&password=short&confirm=short");
381- let (status, _, html) = send(&router, "POST", &path, Some(&cookie), Some(&form)).await;
381+ let (status, _, html) = send(router, "POST", &path, Some(&cookie), Some(&form)).await;
382382 assert_eq!(status, 200);
383383 assert!(
384384 html.contains("Set a new password"),
crates/forge-web/src/pages/new_repo.rsmodified+2 -1
@@ -498,7 +498,8 @@ mod tests {
498498 #[tokio::test]
499499 async fn default_labels_are_added_only_when_checked() {
500500 let site = site().await;
501- let cases: [(&str, &[(&str, &str)], usize); 2] = [
501+ type Case<'a> = (&'a str, &'a [(&'a str, &'a str)], usize);
502+ let cases: [Case<'_>; 2] = [
502503 ("checked", &[("default_labels", "on")], 9),
503504 ("unchecked", &[], 0),
504505 ];
crates/forge-web/src/signatures.rsmodified+2 -1
@@ -793,7 +793,8 @@ mod tests {
793793 #[test]
794794 fn key_listing_parses_one_key_or_rejects() {
795795 // (name, colon listing, expected Some((primary fingerprint, emails)) or None for rejection)
796- let cases: Vec<(&str, &str, Option<(&str, Vec<&str>)>)> = vec![
796+ type Case<'a> = (&'a str, &'a str, Option<(&'a str, Vec<&'a str>)>);
797+ let cases: Vec<Case<'_>> = vec![
797798 (
798799 "primary fingerprint and emails",
799800 "pub:u:255:22:ABCDEF0123456789ABCDEF0123456789ABCDEF01:1700000000::::::23::0:\n\
crates/forge-web/src/views/heatmap.rsmodified+2 -1
@@ -354,7 +354,8 @@ mod tests {
354354 #[test]
355355 fn a_gap_or_an_old_run_ends_the_current_streak() {
356356 // (case, counts, current streak, longest streak)
357- let cases: [(&str, &[(&str, u32)], u64, u64); 2] = [
357+ type Case<'a> = (&'a str, &'a [(&'a str, u32)], u64, u64);
358+ let cases: [Case<'_>; 2] = [
358359 (
359360 "old run",
360361 &[("2026-10-01", 3), ("2026-10-02", 3)],