aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2017-11-08 21:11:12 +0100
committerTeddy Wing2017-11-08 21:11:12 +0100
commit13e82e9dad7f18cf7371b4aab1ade63ef651313e (patch)
treecfbb4e073014a551dc58f8f3af7075ec33123f4f /src
parent7fc89d6d3b9fb12adcfe11609683d53d37b959fd (diff)
downloadkipper-13e82e9dad7f18cf7371b4aab1ade63ef651313e.tar.bz2
jenkins.rs: Make `get_jobs` test real
Instead of just calling the `get_jobs` function, make this a real test and check its return value using a mocked response, now that we have 'mockito' at our disposition.
Diffstat (limited to 'src')
-rw-r--r--src/jenkins.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/jenkins.rs b/src/jenkins.rs
index 46ccbd5..a82084e 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -124,7 +124,37 @@ mod tests {
#[test]
fn get_jobs_queries_jobs_from_jenkins_api() {
- get_jobs("changes".to_string());
+ let mock = mock("GET", "/job/changes-branches/api/json")
+ .with_status(200)
+ .with_header("content-type", "application/json;charset=utf-8")
+ .with_body(r#"
+ {
+ "displayName": "changes-branches",
+ "builds": [
+ {
+ "_class": "hudson.model.FreeStyleBuild",
+ "number": 18,
+ "url": "http://jenkins.example.com/job/changes-branches/18/"
+ },
+ {
+ "_class": "hudson.model.FreeStyleBuild",
+ "number": 17,
+ "url": "http://jenkins.example.com/job/changes-branches/17/"
+ }
+ ]
+ }
+ "#)
+ .create();
+
+ let jobs = get_jobs("changes".to_string());
+
+ assert_eq!(
+ jobs,
+ [
+ "http://jenkins.example.com/job/changes-branches/18/",
+ "http://jenkins.example.com/job/changes-branches/17/"
+ ]
+ );
}
#[test]