Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "The tool that helps optimize the code review process."
documentation = "https://github.com/frisoft/ateam"
repository = "https://github.com/frisoft/ateam"
readme = "README.md"
edition = "2021"
edition = "2024"
keywords = ["cli", "github", "code-review", "pull-request", "command-line"]

[lints.clippy]
Expand Down Expand Up @@ -56,3 +56,6 @@ clap = { version = "4", features = ["derive"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
futures = "0.3"

[dev-dependencies]
temp-env = "0.3"

2 changes: 1 addition & 1 deletion src/client/blame.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Write;

use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use futures::stream::{FuturesUnordered, StreamExt};
use graphql_client::{GraphQLQuery, Response};

Expand Down
8 changes: 2 additions & 6 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Write;

use super::cli::PrArgs;
use super::types::{Files, Label, Labels, Pr, ReviewRequested, Score, ScoredPr, TestsState};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use chrono::prelude::{DateTime as DT, Utc};
use graphql_client::{GraphQLQuery, QueryBody, Response};
use itertools::Itertools;
Expand Down Expand Up @@ -201,11 +201,7 @@ fn github_query(username: &str, options: &PrArgs) -> String {
}

fn query_drafts(include_drafts: bool) -> &'static str {
if include_drafts {
""
} else {
"draft:false "
}
if include_drafts { "" } else { "draft:false " }
}

fn query_mine(username: &str, only_mine: bool) -> String {
Expand Down
32 changes: 16 additions & 16 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ pub fn get_config() -> Result<Config, envy::Error> {
#[cfg(test)]
mod tests {
use super::*;
use std::env;

#[test]
fn test_config_deserialization() {
env::set_var("GITHUB_API_TOKEN", "test_token_abc123");
let result: Result<Config, _> = envy::from_env();
let config = result.expect("Failed to deserialize");
assert_eq!(config.github_api_token, "test_token_abc123");
env::remove_var("GITHUB_API_TOKEN");
temp_env::with_var("GITHUB_API_TOKEN", Some("test_token_abc123"), || {
let result: Result<Config, _> = envy::from_env();
let config = result.expect("Failed to deserialize");
assert_eq!(config.github_api_token, "test_token_abc123");
});
}

#[test]
fn test_config_missing_token() {
// First ensure any leftover token from other tests is removed
env::remove_var("GITHUB_API_TOKEN");

// Also unset any dotenv override
std::env::remove_var("GITHUB_TOKEN");

let result: Result<Config, _> = envy::from_env();
// This test might be flaky if .env file exists in test environment
// Just verify it doesn't panic
let _ = result;
// Unset both GITHUB_API_TOKEN and any dotenv override (GITHUB_TOKEN)
temp_env::with_vars(
[
("GITHUB_API_TOKEN", None::<&str>),
("GITHUB_TOKEN", None::<&str>),
],
|| {
let result: Result<Config, _> = envy::from_env();
let _ = result; // Just verify it doesn't panic
},
);
}
}
8 changes: 2 additions & 6 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::types::{Files, Review, ScoredPr, TestsState};
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::presets::UTF8_FULL;
use comfy_table::{ColumnConstraint, ContentArrangement, Table};
use terminal_size::{terminal_size, Height, Width};
use terminal_size::{Height, Width, terminal_size};

#[cfg(test)]
use super::types::{Labels, Pr, ReviewState, Score};
Expand Down Expand Up @@ -79,11 +79,7 @@ fn pr_row(spr: &ScoredPr, debug: bool) -> Vec<String> {
const YES: &str = "yes";
const NO: &str = "no";
fn show_bool(value: bool) -> &'static str {
if value {
YES
} else {
NO
}
if value { YES } else { NO }
}

fn tests_result_label(tests_result: &TestsState) -> &'static str {
Expand Down