aboutsummaryrefslogtreecommitdiffstats
path: root/src/jenkins.rs
diff options
context:
space:
mode:
authorTeddy Wing2017-11-12 20:06:13 +0100
committerTeddy Wing2017-11-12 20:06:13 +0100
commit81390cd0d3b36f732f6e6071160fb944e1f12892 (patch)
tree6b1bdace5e4b43ca7c0ef82916e3e83d964d88d8 /src/jenkins.rs
parentc3eac830c7713f2e2740b95fe2ef3664ae0a021d (diff)
downloadkipper-81390cd0d3b36f732f6e6071160fb944e1f12892.tar.bz2
Update tests for Jenkins mock URL
Now that the Jenkins API URL is getting passed in via command line and function argument, update the tests to pass it in directly. Remove the test/non-test versions of `jenkins_url` from `find_and_track_build_and_update_status()` because we can pass in the mock URL directly to the `get_jobs()` and `request_job()` functions in tests. Make the `jenkins_url` argument to `find_and_track_build_and_update_status()` not a reference so that we don't have to reset it in the function to a `to_owned()` version.
Diffstat (limited to 'src/jenkins.rs')
-rw-r--r--src/jenkins.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/jenkins.rs b/src/jenkins.rs
index b46f5ae..a41b11c 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -76,7 +76,7 @@ impl Job {
pub fn find_and_track_build_and_update_status(
commit_ref: CommitRef,
- jenkins_url: &String,
+ jenkins_url: String,
jenkins_user_id: &String,
jenkins_token: &String,
github_token: String,
@@ -86,12 +86,6 @@ pub fn find_and_track_build_and_update_status(
&jenkins_token
)?;
- #[cfg(not(test))]
- let jenkins_url = jenkins_url.to_owned();
-
- #[cfg(test)]
- let jenkins_url = mockito::SERVER_URL;
-
let jobs = get_jobs(
&jenkins_url,
&jenkins_client,
@@ -337,8 +331,11 @@ mod tests {
"#)
.create();
- let jobs = get_jobs(&test_request_client(), "changes")
- .expect("Failed to request jobs");
+ let jobs = get_jobs(
+ &mockito::SERVER_URL.to_owned(),
+ &test_request_client(),
+ "changes"
+ ).expect("Failed to request jobs");
assert_eq!(
jobs,
@@ -363,6 +360,7 @@ mod tests {
.create();
let job = request_job(
+ &mockito::SERVER_URL.to_owned(),
&test_request_client(),
"http://jenkins.example.com/job/changes-branches/15"
).expect("Failed to request job");