From e00d162cc09434b4ad8bd48385e92417aedfcf7a Mon Sep 17 00:00:00 2001 From: joaolfp Date: Mon, 5 Jan 2026 22:16:15 -0300 Subject: [PATCH 1/4] fix: comments #35 --- src/cli.rs | 2 +- src/pull_requests.rs | 10 ++++++---- tests/network_tests.rs | 18 ++++++------------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 28b73e6..8a0acdc 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -42,7 +42,7 @@ impl Cli { Clone::clone_repos(true).await?; } Some(Command::Pr) => { - PullRequests::pull_requests_open().await?; + PullRequests::list_open().await?; } None => { println!("Run {}", "heroesofcode --help".blue()); diff --git a/src/pull_requests.rs b/src/pull_requests.rs index 0cc98d1..fe65412 100644 --- a/src/pull_requests.rs +++ b/src/pull_requests.rs @@ -7,8 +7,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct PullRequestItems { - /// Array of all open pull requests + /// Pull requests returned in the current page of results pub items: Vec, + /// Total number of matching open pull requests across all pages pub total_count: usize, } @@ -19,11 +20,11 @@ pub struct PullRequestResponse { /// PR title pub title: String, /// User information who opened the PR - pub user: User, + pub user: PullRequestUser, } #[derive(Debug, Serialize, Deserialize)] -pub struct User { +pub struct PullRequestUser { /// Username of the user who opened the PR pub login: String, } @@ -31,7 +32,8 @@ pub struct User { pub struct PullRequests; impl PullRequests { - pub async fn pull_requests_open() -> Result<(), reqwest::Error> { + /// Fetch all open pull requests + pub async fn list_open() -> Result<(), reqwest::Error> { match Self::response().await { Ok(result) => { println!(); diff --git a/tests/network_tests.rs b/tests/network_tests.rs index bc4787b..263b09c 100644 --- a/tests/network_tests.rs +++ b/tests/network_tests.rs @@ -62,16 +62,10 @@ async fn test_get_pull_requests() { ); let result = network.get_json::(url).await; - match &result { - Ok(prs) => { - assert_eq!(prs.total_count, 2); - assert_eq!(prs.items.len(), 2); - assert_eq!(prs.items[0].title, "Test PR 1"); - assert_eq!(prs.items[0].user.login, "testuser1"); - } - Err(e) => { - eprintln!("Error: {}", e); - panic!("Request failed: {}", e); - } - } + assert!(result.is_ok()); + let prs = result.unwrap(); + assert_eq!(prs.total_count, 2); + assert_eq!(prs.items.len(), 2); + assert_eq!(prs.items[0].title, "Test PR 1"); + assert_eq!(prs.items[0].user.login, "testuser1"); } From d2c512449239e9feecae0a43064ddc5ef5f8b2f5 Mon Sep 17 00:00:00 2001 From: joaolfp Date: Mon, 5 Jan 2026 22:28:51 -0300 Subject: [PATCH 2/4] fix: copilot comments --- src/pull_requests.rs | 2 +- tests/network_tests.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pull_requests.rs b/src/pull_requests.rs index fe65412..62224ff 100644 --- a/src/pull_requests.rs +++ b/src/pull_requests.rs @@ -19,7 +19,7 @@ pub struct PullRequestResponse { pub html_url: String, /// PR title pub title: String, - /// User information who opened the PR + /// User information for the user who opened the PR pub user: PullRequestUser, } diff --git a/tests/network_tests.rs b/tests/network_tests.rs index 263b09c..37f703e 100644 --- a/tests/network_tests.rs +++ b/tests/network_tests.rs @@ -62,10 +62,8 @@ async fn test_get_pull_requests() { ); let result = network.get_json::(url).await; - assert!(result.is_ok()); - let prs = result.unwrap(); + let prs = result.expect("Failed to get pull requests"); assert_eq!(prs.total_count, 2); assert_eq!(prs.items.len(), 2); - assert_eq!(prs.items[0].title, "Test PR 1"); - assert_eq!(prs.items[0].user.login, "testuser1"); + assert_eq!(prs.items.len(), 2); } From a05586bf46450fa688f0d924bdfc451b5ccc7e74 Mon Sep 17 00:00:00 2001 From: joaolfp Date: Mon, 5 Jan 2026 22:32:19 -0300 Subject: [PATCH 3/4] fix: remove duplicate code --- tests/network_tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/network_tests.rs b/tests/network_tests.rs index 37f703e..37faba4 100644 --- a/tests/network_tests.rs +++ b/tests/network_tests.rs @@ -65,5 +65,4 @@ async fn test_get_pull_requests() { let prs = result.expect("Failed to get pull requests"); assert_eq!(prs.total_count, 2); assert_eq!(prs.items.len(), 2); - assert_eq!(prs.items.len(), 2); } From cbb5af4dcb57a9b862983482e4d29037decd6e30 Mon Sep 17 00:00:00 2001 From: joaolfp Date: Mon, 5 Jan 2026 22:41:40 -0300 Subject: [PATCH 4/4] fix: improvement function comment --- src/pull_requests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pull_requests.rs b/src/pull_requests.rs index 62224ff..e58d69d 100644 --- a/src/pull_requests.rs +++ b/src/pull_requests.rs @@ -32,7 +32,7 @@ pub struct PullRequestUser { pub struct PullRequests; impl PullRequests { - /// Fetch all open pull requests + /// Fetch open pull requests (first page of paginated results) pub async fn list_open() -> Result<(), reqwest::Error> { match Self::response().await { Ok(result) => {