From 6a2f2232cb3bd26e512c1383a581544bc0aef731 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 17 Nov 2017 01:26:13 +0100 Subject: jenkins.rs: Add `jenkins_console_url_path()` A new function that will return the URL to the Jenkins "Console" page given the URL of a Jenkins job. We'll be using this to pass with the GitHub status request as the `target_url`. --- src/jenkins.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/jenkins.rs b/src/jenkins.rs index 2cd4858..67e6c20 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -281,6 +281,10 @@ pub fn result_from_job(status: Option) -> JobStatus { } } +pub fn jenkins_console_url_path(job_url: &String) -> String { + format!("{}console", job_url) +} + fn jenkins_request_client(user_id: &String, token: &String) -> Result> { let credentials = auth_credentials(user_id.to_owned(), token.to_owned()); @@ -446,4 +450,14 @@ mod tests { JobStatus::Pending ); } + + #[test] + fn jenkins_console_url_path_returns_url_to_console_page() { + assert_eq!( + jenkins_console_url_path( + &"https://jenkins.example.com/job/changes-branches/15/".to_owned() + ), + "https://jenkins.example.com/job/changes-branches/15/console" + ); + } } -- cgit v1.2.3