More tests (#729)

* permissions tests

* finished permissions; organization tests

* clippy, fmt

* post-merge fixes

* teams changes

* refactored to use new api

* fmt, clippy

* sqlx prepare

* revs

* revs

* re-tested

* re-added name

* reverted to matrix
This commit is contained in:
Wyatt Verchere
2023-10-17 00:53:10 -07:00
committed by GitHub
parent abf4cd71ba
commit 9d0e762f36
27 changed files with 4060 additions and 555 deletions

View File

@@ -7,6 +7,15 @@ use crate::common::{dummy_data::DummyJarFile, request_data::get_public_project_c
mod common;
// user GET (permissions, different users)
// users GET
// user auth
// user projects get
// user collections get
// patch user
// patch user icon
// user follows
#[actix_rt::test]
pub async fn get_user_projects_after_creating_project_returns_new_project() {
with_test_environment(|test_env| async move {
@@ -15,10 +24,10 @@ pub async fn get_user_projects_after_creating_project_returns_new_project() {
.await;
let (project, _) = api
.add_public_project(get_public_project_creation_data(
"slug",
DummyJarFile::BasicMod,
))
.add_public_project(
get_public_project_creation_data("slug", Some(DummyJarFile::BasicMod)),
USER_USER_PAT,
)
.await;
let resp_projects = api
@@ -34,15 +43,15 @@ pub async fn get_user_projects_after_deleting_project_shows_removal() {
with_test_environment(|test_env| async move {
let api = test_env.v2;
let (project, _) = api
.add_public_project(get_public_project_creation_data(
"iota",
DummyJarFile::BasicMod,
))
.add_public_project(
get_public_project_creation_data("iota", Some(DummyJarFile::BasicMod)),
USER_USER_PAT,
)
.await;
api.get_user_projects_deserialized(USER_USER_ID, USER_USER_PAT)
.await;
api.remove_project(&project.slug.as_ref().unwrap(), USER_USER_PAT)
api.remove_project(project.slug.as_ref().unwrap(), USER_USER_PAT)
.await;
let resp_projects = api
@@ -56,15 +65,15 @@ pub async fn get_user_projects_after_deleting_project_shows_removal() {
#[actix_rt::test]
pub async fn get_user_projects_after_joining_team_shows_team_projects() {
with_test_environment(|test_env| async move {
let alpha_team_id = &test_env.dummy.as_ref().unwrap().alpha_team_id;
let alpha_project_id = &test_env.dummy.as_ref().unwrap().alpha_project_id;
let alpha_team_id = &test_env.dummy.as_ref().unwrap().project_alpha.team_id;
let alpha_project_id = &test_env.dummy.as_ref().unwrap().project_alpha.project_id;
let api = test_env.v2;
api.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
.await;
api.add_user_to_team(alpha_team_id, FRIEND_USER_ID, USER_USER_PAT)
api.add_user_to_team(alpha_team_id, FRIEND_USER_ID, None, None, USER_USER_PAT)
.await;
api.join_team(&alpha_team_id, FRIEND_USER_PAT).await;
api.join_team(alpha_team_id, FRIEND_USER_PAT).await;
let projects = api
.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
@@ -79,16 +88,16 @@ pub async fn get_user_projects_after_joining_team_shows_team_projects() {
#[actix_rt::test]
pub async fn get_user_projects_after_leaving_team_shows_no_team_projects() {
with_test_environment(|test_env| async move {
let alpha_team_id = &test_env.dummy.as_ref().unwrap().alpha_team_id;
let alpha_project_id = &test_env.dummy.as_ref().unwrap().alpha_project_id;
let alpha_team_id = &test_env.dummy.as_ref().unwrap().project_alpha.team_id;
let alpha_project_id = &test_env.dummy.as_ref().unwrap().project_alpha.project_id;
let api = test_env.v2;
api.add_user_to_team(alpha_team_id, FRIEND_USER_ID, USER_USER_PAT)
api.add_user_to_team(alpha_team_id, FRIEND_USER_ID, None, None, USER_USER_PAT)
.await;
api.join_team(&alpha_team_id, FRIEND_USER_PAT).await;
api.join_team(alpha_team_id, FRIEND_USER_PAT).await;
api.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
.await;
api.remove_from_team(&alpha_team_id, FRIEND_USER_ID, USER_USER_PAT)
api.remove_from_team(alpha_team_id, FRIEND_USER_ID, USER_USER_PAT)
.await;
let projects = api