octocrate 0.3.0

A comprehensive GitHub REST API library based on Rust.
Documentation
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();

  // https://github.com/panghu-huang/octocrate/pull/1/files
  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);

  // 404 not merged
  let res = api
    .pulls
    // https://github.com/panghu-huang/octocrate/pull/1
    .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");
  }

  // 204 merged
  let res = api
    .pulls
    // https://github.com/panghu-huang/octocrate/pull/2
    .check_if_merged("panghu-huang", "octocrate", 2)
    .send()
    .await;

  assert!(res.is_ok());
}