Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
✅ simple test on post
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed May 15, 2018
1 parent a0fc28a commit f523f2a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,28 @@ impl Jenkins {
Ok(Self::error_for_status(response)?)
}
}

#[cfg(test)]
mod tests {
extern crate mockito;

static JENKINS_URL: &'static str = mockito::SERVER_URL;

#[test]
fn can_post_with_body() {
let jenkins_client = ::JenkinsBuilder::new(JENKINS_URL)
.disable_csrf()
.build()
.unwrap();

let _mock = mockito::mock("POST", "/mypath?").with_body("ok").create();

let response =
jenkins_client.post_with_body(&super::Path::Raw { path: "/mypath" }, "body", &[]);
println!("{:?}", response);

assert!(response.is_ok());
assert_eq!(response.unwrap().text().unwrap(), "ok");
}

}

0 comments on commit f523f2a

Please sign in to comment.