use octocrate::{APIConfig, Error, GitHubAPI};
#[tokio::test]
async fn test_get_pull_request() {
let config = APIConfig::default().shared();
let api = GitHubAPI::new(&config);
let pull_request = api
.pulls
.get("panghu-huang", "octocrate", 1)
.send()
.await
.unwrap();
assert_eq!(pull_request.number, 1);
}
#[tokio::test]
async fn test_list_pull_request_changed_files() {
let config = APIConfig::default().shared();
let api = GitHubAPI::new(&config);
let files = api
.pulls
.list_files("panghu-huang", "octocrate", 1)
.send()
.await
.unwrap();
assert_eq!(files.len(), 1);
}
#[tokio::test]
async fn test_check_if_pull_request_has_been_merged() {
let config = APIConfig::default().shared();
let api = GitHubAPI::new(&config);
let res = api
.pulls
.check_if_merged("panghu-huang", "octocrate", 1)
.send()
.await;
let err = res.unwrap_err();
if let Error::RequestFailed(error) = err {
assert_eq!(error.message, "Not Found");
} else {
panic!("Expected RequestFailed");
}
let res = api
.pulls
.check_if_merged("panghu-huang", "octocrate", 2)
.send()
.await;
assert!(res.is_ok());
}