Skip to content

Commit

Permalink
Add test for get_env_name_api_endpoint_for_host
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Aug 30, 2024
1 parent 8a62530 commit 5de106e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/api_clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ impl<C: Client> ClientSet<C> {
}
}

// TODO: add test
fn get_env_name_api_endpoint_for_host(host: &str) -> (String, String) {
let mut env_name = "GITHUB_TOKEN".to_string();
let mut api_endpoint = "https://api.github.com".to_string();
Expand All @@ -338,3 +337,19 @@ fn get_env_name_api_endpoint_for_host(host: &str) -> (String, String) {

(env_name, api_endpoint)
}

#[cfg(test)]
mod tests {
use crate::api_clients;

#[test]
fn get_env_name_api_endpoint_for_host() {
let (env_name, api_endpoint) = api_clients::get_env_name_api_endpoint_for_host("github.com");
assert_eq!(env_name, "GITHUB_TOKEN");
assert_eq!(api_endpoint, "https://api.github.com");

let (env_name, api_endpoint) = api_clients::get_env_name_api_endpoint_for_host("github.example.com");
assert_eq!(env_name, "GITHUB_EXAMPLE_COM_TOKEN");
assert_eq!(api_endpoint, "https://github.example.com/api/v3");
}
}

0 comments on commit 5de106e

Please sign in to comment.