diff options
author | Teddy Wing | 2017-11-12 20:06:13 +0100 |
---|---|---|
committer | Teddy Wing | 2017-11-12 20:06:13 +0100 |
commit | 81390cd0d3b36f732f6e6071160fb944e1f12892 (patch) | |
tree | 6b1bdace5e4b43ca7c0ef82916e3e83d964d88d8 /src | |
parent | c3eac830c7713f2e2740b95fe2ef3664ae0a021d (diff) | |
download | kipper-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')
-rw-r--r-- | src/jenkins.rs | 16 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 8 insertions, 10 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"); diff --git a/src/main.rs b/src/main.rs index fdcdeeb..3f3351a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,7 +105,7 @@ fn main() { match jenkins::find_and_track_build_and_update_status( commit_ref, - &jenkins_url, + jenkins_url.clone(), &jenkins_user_id, &jenkins_token, github_token.clone(), |