Add a friendship test (:3)
This commit is contained in:
parent
94c98cfce4
commit
4640ecf604
|
@ -1,4 +1,4 @@
|
||||||
use chorus::types::{self, RegisterSchema, RegisterSchemaOptions};
|
use chorus::types::{self, RegisterSchema, RegisterSchemaOptions, Relationship, RelationshipType};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
@ -47,6 +47,61 @@ async fn test_get_relationships() {
|
||||||
};
|
};
|
||||||
other_user.send_friend_request(friend_request_schema).await;
|
other_user.send_friend_request(friend_request_schema).await;
|
||||||
let relationships = user.get_relationships().await.unwrap();
|
let relationships = user.get_relationships().await.unwrap();
|
||||||
println!("{:?}", relationships);
|
assert_eq!(relationships.get(0).unwrap().id, other_user.object.id);
|
||||||
|
common::teardown(bundle).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_modify_relationship_friends() {
|
||||||
|
let register_schema = RegisterSchemaOptions {
|
||||||
|
date_of_birth: Some("2000-01-01".to_string()),
|
||||||
|
..RegisterSchema::builder("integrationtestuser2", true)
|
||||||
|
}
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut bundle = common::setup().await;
|
||||||
|
let belongs_to = &mut bundle.instance;
|
||||||
|
let user = &mut bundle.user;
|
||||||
|
let mut other_user = belongs_to.register_account(®ister_schema).await.unwrap();
|
||||||
|
other_user
|
||||||
|
.modify_user_relationship(
|
||||||
|
&user.object.id.to_string(),
|
||||||
|
types::RelationshipType::Friends,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let relationships = user.get_relationships().await.unwrap();
|
||||||
|
assert_eq!(relationships.get(0).unwrap().id, other_user.object.id);
|
||||||
|
assert_eq!(
|
||||||
|
relationships.get(0).unwrap().relationship_type,
|
||||||
|
RelationshipType::Incoming
|
||||||
|
);
|
||||||
|
let relationships = other_user.get_relationships().await.unwrap();
|
||||||
|
assert_eq!(relationships.get(0).unwrap().id, user.object.id);
|
||||||
|
assert_eq!(
|
||||||
|
relationships.get(0).unwrap().relationship_type,
|
||||||
|
RelationshipType::Outgoing
|
||||||
|
);
|
||||||
|
user.modify_user_relationship(
|
||||||
|
other_user.object.id.to_string().as_str(),
|
||||||
|
RelationshipType::Friends,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(
|
||||||
|
other_user
|
||||||
|
.get_relationships()
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.get(0)
|
||||||
|
.unwrap()
|
||||||
|
.relationship_type,
|
||||||
|
RelationshipType::Friends
|
||||||
|
);
|
||||||
|
user.remove_relationship(other_user.object.id.to_string().as_str())
|
||||||
|
.await;
|
||||||
|
assert_eq!(
|
||||||
|
other_user.get_relationships().await.unwrap(),
|
||||||
|
Vec::<Relationship>::new()
|
||||||
|
);
|
||||||
common::teardown(bundle).await
|
common::teardown(bundle).await
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue