aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-11-08 23:05:34 +0100
committerTeddy Wing2017-11-08 23:07:31 +0100
commit0f1f1b2f2991e30672706b58ca4af5b2cc1c92cf (patch)
tree525255a099206bd05bda84fd2452c178bb45cbbb
parent32ad1916123325a8cc80fb76e0cbd5a2bb0b6841 (diff)
downloadkipper-0f1f1b2f2991e30672706b58ca4af5b2cc1c92cf.tar.bz2
jenkins.rs: Allow `request_job` to work with the test mock
Use the 'url' crate to split the passed in URL string and get its path part so we can use the mock HTTP server for testing. Otherwise, this requested the real Jenkins API URL and we couldn't test it.
-rw-r--r--src/jenkins.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/jenkins.rs b/src/jenkins.rs
index ff15428..9312113 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -23,8 +23,10 @@
extern crate json;
extern crate mockito;
extern crate reqwest;
+extern crate url;
use self::reqwest::header::{Authorization, Basic};
+use self::url::Url;
use af83;
use pull_request::CommitRef;
@@ -102,11 +104,13 @@ pub fn get_jobs(repo_name: String) -> Vec<String> {
}
pub fn request_job(url: String) -> Job {
+ let url = Url::parse(url.as_ref()).unwrap();
+
let client = reqwest::Client::new();
let credentials = auth_credentials();
- let mut response = client.get(&format!("{}/api/json", url))
+ let mut response = client.get(&format!("{}{}/api/json", API_URL, url.path()))
.header(Authorization(credentials))
.send()
.unwrap();