diff --git a/Cargo.lock b/Cargo.lock index fdce6b8..02c2e88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -58,7 +58,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -258,7 +258,7 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -379,9 +379,9 @@ dependencies = [ [[package]] name = "demand" -version = "2.0.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35fbd3e6864d5351323ef4fa5db803386adf73cce6b42fcdf6a542804dc83c61" +checksum = "907231cc77f104ad0777b4c06370cc1513e0f1181983dc617059630e6b79f36f" dependencies = [ "console", "fuzzy-matcher", @@ -418,7 +418,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -493,7 +493,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1223,7 +1223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.45.0", + "windows-sys 0.61.2", ] [[package]] @@ -1537,7 +1537,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1594,7 +1594,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2340,7 +2340,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 34a925e..a9583ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ tokio = { version = "1.48.0", features = ["full"] } serde = { version = "1.0.228", features = ["derive"] } clap = { version = "4.5.53", features = ["derive"] } comfy-table = "7.2.1" -demand = "2.0.0" +demand = "1.8.2" console = "0.16.2" colored = "3.0.0" httpmock = "0.8.2" diff --git a/src/repos.rs b/src/repos.rs index 0f7241e..9e5fcf5 100644 --- a/src/repos.rs +++ b/src/repos.rs @@ -9,6 +9,7 @@ use crate::{cli_output::CliOutput, network::Network}; pub struct RepoResponse { pub name: String, pub html_url: String, + pub archived: bool, } /// Repository operations handler @@ -37,11 +38,12 @@ impl Repos { } } - /// Requests the repository list from the API + /// Requests the repository list from the API, excluding archived repositories pub async fn response() -> Result, reqwest::Error> { let network = Network::new(); let url = format!("{}/orgs/heroesofcode/repos", network.base_url()); - network.get_json(&url).await + let repos: Vec = network.get_json(&url).await?; + Ok(repos.into_iter().filter(|r| !r.archived).collect()) } /// Renders repository data in a terminal table diff --git a/tests/network_tests.rs b/tests/network_tests.rs index e36b933..eaf0b5e 100644 --- a/tests/network_tests.rs +++ b/tests/network_tests.rs @@ -13,11 +13,13 @@ async fn test_get_json_success() { then.status(200).json_body_obj(&vec![ serde_json::json!({ "name": "ViewState", - "html_url": "https://github.com/heroesofcode/ViewState" + "html_url": "https://github.com/heroesofcode/ViewState", + "archived": false }), serde_json::json!({ "name": "DataLife", - "html_url": "https://github.com/heroesofcode/DataLife" + "html_url": "https://github.com/heroesofcode/DataLife", + "archived": false }), ]); }); diff --git a/tests/repos_tests.rs b/tests/repos_tests.rs index 7039f7e..5b97aa2 100644 --- a/tests/repos_tests.rs +++ b/tests/repos_tests.rs @@ -7,7 +7,8 @@ use httpmock::MockServer; fn test_repo_response_deserialization() { let json = r#"{ "name": "test-repo", - "html_url": "https://github.com/heroesofcode/test-repo" + "html_url": "https://github.com/heroesofcode/test-repo", + "archived": false }"#; let repo: RepoResponse = serde_json::from_str(json).unwrap(); @@ -38,9 +39,9 @@ async fn test_repos_multiple_items() { server.mock(|when, then| { when.method(GET).path("/orgs/heroesofcode/repos"); then.status(200).json_body_obj(&vec![ - serde_json::json!({"name": "repo1", "html_url": "https://github.com/heroesofcode/repo1"}), - serde_json::json!({"name": "repo2", "html_url": "https://github.com/heroesofcode/repo2"}), - serde_json::json!({"name": "repo3", "html_url": "https://github.com/heroesofcode/repo3"}), + serde_json::json!({"name": "repo1", "html_url": "https://github.com/heroesofcode/repo1", "archived": false}), + serde_json::json!({"name": "repo2", "html_url": "https://github.com/heroesofcode/repo2", "archived": false}), + serde_json::json!({"name": "repo3", "html_url": "https://github.com/heroesofcode/repo3", "archived": false}), ]); });