Tests v2 recreate (#760)

* added common project information; setup for v2 test change

* all tests now use with_test_environment

* progress, failing

* finished re-adding tests

* prepare

* cargo sqlx prepare -- --tests

* fmt; clippy; prepare

* sqlx prepare

* adds version_create fix and corresponding test

* merge fixes; rev

* fmt, clippy, prepare

* test cargo sqlx prepare
This commit is contained in:
Wyatt Verchere
2023-11-25 13:42:39 -08:00
committed by GitHub
parent ade8c162cd
commit 172b93d07f
51 changed files with 7573 additions and 6631 deletions

View File

@@ -1,11 +1,10 @@
use crate::common::api_common::{ApiProject, ApiTeams};
use common::dummy_data::TestFile;
use common::{
database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_ID, USER_USER_PAT},
environment::with_test_environment,
environment::with_test_environment_all,
};
use crate::common::api_v3::request_data::get_public_project_creation_data;
use common::dummy_data::TestFile;
mod common;
// user GET (permissions, different users)
@@ -19,20 +18,17 @@ mod common;
#[actix_rt::test]
pub async fn get_user_projects_after_creating_project_returns_new_project() {
with_test_environment(|test_env| async move {
let api = test_env.v3;
api.get_user_projects_deserialized(USER_USER_ID, USER_USER_PAT)
with_test_environment_all(None, |test_env| async move {
let api = test_env.api;
api.get_user_projects_deserialized_common(USER_USER_ID, USER_USER_PAT)
.await;
let (project, _) = api
.add_public_project(
get_public_project_creation_data("slug", Some(TestFile::BasicMod)),
USER_USER_PAT,
)
.add_public_project("slug", Some(TestFile::BasicMod), None, USER_USER_PAT)
.await;
let resp_projects = api
.get_user_projects_deserialized(USER_USER_ID, USER_USER_PAT)
.get_user_projects_deserialized_common(USER_USER_ID, USER_USER_PAT)
.await;
assert!(resp_projects.iter().any(|p| p.id == project.id));
})
@@ -41,22 +37,19 @@ pub async fn get_user_projects_after_creating_project_returns_new_project() {
#[actix_rt::test]
pub async fn get_user_projects_after_deleting_project_shows_removal() {
with_test_environment(|test_env| async move {
let api = test_env.v3;
with_test_environment_all(None, |test_env| async move {
let api = test_env.api;
let (project, _) = api
.add_public_project(
get_public_project_creation_data("iota", Some(TestFile::BasicMod)),
USER_USER_PAT,
)
.add_public_project("iota", Some(TestFile::BasicMod), None, USER_USER_PAT)
.await;
api.get_user_projects_deserialized(USER_USER_ID, USER_USER_PAT)
api.get_user_projects_deserialized_common(USER_USER_ID, USER_USER_PAT)
.await;
api.remove_project(project.slug.as_ref().unwrap(), USER_USER_PAT)
.await;
let resp_projects = api
.get_user_projects_deserialized(USER_USER_ID, USER_USER_PAT)
.get_user_projects_deserialized_common(USER_USER_ID, USER_USER_PAT)
.await;
assert!(!resp_projects.iter().any(|p| p.id == project.id));
})
@@ -65,11 +58,11 @@ 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 {
with_test_environment_all(None, |test_env| async move {
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.v3;
api.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
let api = test_env.api;
api.get_user_projects_deserialized_common(FRIEND_USER_ID, FRIEND_USER_PAT)
.await;
api.add_user_to_team(alpha_team_id, FRIEND_USER_ID, None, None, USER_USER_PAT)
@@ -77,7 +70,7 @@ pub async fn get_user_projects_after_joining_team_shows_team_projects() {
api.join_team(alpha_team_id, FRIEND_USER_PAT).await;
let projects = api
.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
.get_user_projects_deserialized_common(FRIEND_USER_ID, FRIEND_USER_PAT)
.await;
assert!(projects
.iter()
@@ -88,21 +81,21 @@ 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 {
with_test_environment_all(None, |test_env| async move {
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.v3;
let api = test_env.api;
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.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
api.get_user_projects_deserialized_common(FRIEND_USER_ID, FRIEND_USER_PAT)
.await;
api.remove_from_team(alpha_team_id, FRIEND_USER_ID, USER_USER_PAT)
.await;
let projects = api
.get_user_projects_deserialized(FRIEND_USER_ID, FRIEND_USER_PAT)
.get_user_projects_deserialized_common(FRIEND_USER_ID, FRIEND_USER_PAT)
.await;
assert!(!projects
.iter()