Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmhewitt committed May 10, 2023
1 parent 583ed26 commit e8227d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/api/current.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Get data about the currently authenticated user.
use crate::{
models::{self, gists::Gist, Repository, orgs::{MembershipInvitation}},
models::{self, gists::Gist, orgs::MembershipInvitation, Repository},
Octocrab, Page, Result,
};
use chrono::{DateTime, Utc};
Expand Down Expand Up @@ -138,7 +138,9 @@ impl<'octo> CurrentAuthHandler<'octo> {
/// ```
///
/// [See the GitHub API documentation](https://docs.github.com/en/rest/orgs/members#list-organization-memberships-for-the-authenticated-user)
pub fn list_org_memberships_for_authenticated_user(&self) -> ListOrgMembershipsForAuthenticatedUserBuilder<'octo> {
pub fn list_org_memberships_for_authenticated_user(
&self,
) -> ListOrgMembershipsForAuthenticatedUserBuilder<'octo> {
ListOrgMembershipsForAuthenticatedUserBuilder::new(self.crab)
}
}
Expand Down Expand Up @@ -512,6 +514,8 @@ impl<'octo> ListOrgMembershipsForAuthenticatedUserBuilder<'octo> {

/// Sends the actual request.
pub async fn send(self) -> crate::Result<Page<MembershipInvitation>> {
self.crab.get("/user/memberships/orgs", (&self).into()).await
self.crab
.get("/user/memberships/orgs", (&self).into())
.await
}
}
}
15 changes: 10 additions & 5 deletions tests/current_user_orgs_test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Tests for calls to the /user/memberships/orgs API.
mod mock_error;

use octocrab::{models::orgs::MembershipInvitation, Octocrab, Page};
use serde::{Serialize, Deserialize};
use wiremock::{ResponseTemplate, MockServer, Mock, matchers::{method, path}};
use mock_error::setup_error_handler;
use octocrab::{models::orgs::MembershipInvitation, Octocrab, Page};
use serde::{Deserialize, Serialize};
use wiremock::{
matchers::{method, path},
Mock, MockServer, ResponseTemplate,
};

#[derive(Serialize, Deserialize)]
struct FakePage<T> {
Expand Down Expand Up @@ -41,7 +44,9 @@ async fn should_return_page_with_invitations() {
let template = ResponseTemplate::new(200).set_body_json(&page_response);
let mock_server = setup_api(template).await;
let client = setup_octocrab(&mock_server.uri());
let orgs = client.current().list_org_memberships_for_authenticated_user();
let orgs = client
.current()
.list_org_memberships_for_authenticated_user();

let result = orgs.send().await;
assert!(
Expand All @@ -58,4 +63,4 @@ async fn should_return_page_with_invitations() {
assert_eq!(items[0].organization.login, "elementary");
assert_eq!(items[1].organization.login, "EpicGames");
}
}
}

0 comments on commit e8227d2

Please sign in to comment.