You've already forked AstralRinth
forked from didirus/AstralRinth
Fixes failing tests (#813)
* fixes failing tests * fmt clippy * updated dockerfile * fixes failing tests; adds important fix from extracts_versions PR * assert_eq -> assert_status, giving better error messages * fixed random failure bug * fmt, clippy, etc
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
test::{self, TestRequest},
|
||||
@@ -6,7 +7,10 @@ use bytes::Bytes;
|
||||
use labrinth::models::{collections::Collection, v3::projects::Project};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::common::api_common::{request_data::ImageData, Api, AppendsOptionalPat};
|
||||
use crate::common::{
|
||||
api_common::{request_data::ImageData, Api, AppendsOptionalPat},
|
||||
asserts::assert_status,
|
||||
};
|
||||
|
||||
use super::ApiV3;
|
||||
|
||||
@@ -40,7 +44,7 @@ impl ApiV3 {
|
||||
|
||||
pub async fn get_collection_deserialized(&self, id: &str, pat: Option<&str>) -> Collection {
|
||||
let resp = self.get_collection(id, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -70,7 +74,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<Project> {
|
||||
let resp = self.get_collection_projects(id, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -145,7 +149,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<Collection> {
|
||||
let resp = self.get_user_collections(user_id_or_username, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let projects: Vec<Project> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
test::{self, TestRequest},
|
||||
@@ -6,7 +7,10 @@ use bytes::Bytes;
|
||||
use labrinth::models::{organizations::Organization, users::UserId, v3::projects::Project};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::common::api_common::{request_data::ImageData, Api, AppendsOptionalPat};
|
||||
use crate::common::{
|
||||
api_common::{request_data::ImageData, Api, AppendsOptionalPat},
|
||||
asserts::assert_status,
|
||||
};
|
||||
|
||||
use super::ApiV3;
|
||||
|
||||
@@ -14,6 +18,7 @@ impl ApiV3 {
|
||||
pub async fn create_organization(
|
||||
&self,
|
||||
organization_title: &str,
|
||||
organization_slug: &str,
|
||||
description: &str,
|
||||
pat: Option<&str>,
|
||||
) -> ServiceResponse {
|
||||
@@ -22,6 +27,7 @@ impl ApiV3 {
|
||||
.append_pat(pat)
|
||||
.set_json(json!({
|
||||
"name": organization_title,
|
||||
"slug": organization_slug,
|
||||
"description": description,
|
||||
}))
|
||||
.to_request();
|
||||
@@ -42,7 +48,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Organization {
|
||||
let resp = self.get_organization(id_or_title, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -80,7 +86,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<Project> {
|
||||
let resp = self.get_organization_projects(id_or_title, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ impl ApiProject for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> CommonProject {
|
||||
let resp = self.get_project(id_or_slug, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let project: Project = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -169,7 +169,7 @@ impl ApiProject for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<CommonProject> {
|
||||
let resp = self.get_user_projects(user_id_or_username, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let projects: Vec<Project> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -383,10 +383,7 @@ impl ApiProject for ApiV3 {
|
||||
.append_pat(pat)
|
||||
.to_request();
|
||||
|
||||
let t = self.call(req).await;
|
||||
println!("Status: {}", t.status());
|
||||
println!("respone Body: {:?}", t.response().body());
|
||||
t
|
||||
self.call(req).await
|
||||
}
|
||||
|
||||
async fn remove_gallery_item(
|
||||
@@ -480,7 +477,7 @@ impl ApiProject for ApiV3 {
|
||||
impl ApiV3 {
|
||||
pub async fn get_project_deserialized(&self, id_or_slug: &str, pat: Option<&str>) -> Project {
|
||||
let resp = self.get_project(id_or_slug, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -503,7 +500,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Organization {
|
||||
let resp = self.get_project_organization(id_or_slug, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -530,8 +527,7 @@ impl ApiV3 {
|
||||
.append_pat(pat)
|
||||
.to_request();
|
||||
let resp = self.call(req).await;
|
||||
let status = resp.status();
|
||||
assert_eq!(status, 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -598,7 +594,7 @@ impl ApiV3 {
|
||||
pat,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
test::{self, TestRequest},
|
||||
@@ -13,6 +14,7 @@ use crate::common::{
|
||||
models::{CommonCategoryData, CommonLoaderData},
|
||||
Api, ApiTags, AppendsOptionalPat,
|
||||
},
|
||||
asserts::assert_status,
|
||||
database::ADMIN_USER_PAT,
|
||||
};
|
||||
|
||||
@@ -30,7 +32,7 @@ impl ApiTags for ApiV3 {
|
||||
|
||||
async fn get_loaders_deserialized_common(&self) -> Vec<CommonLoaderData> {
|
||||
let resp = self.get_loaders().await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Vec<LoaderData> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -48,7 +50,7 @@ impl ApiTags for ApiV3 {
|
||||
|
||||
async fn get_categories_deserialized_common(&self) -> Vec<CommonCategoryData> {
|
||||
let resp = self.get_categories().await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Vec<CategoryData> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -60,7 +62,7 @@ impl ApiTags for ApiV3 {
|
||||
impl ApiV3 {
|
||||
pub async fn get_loaders_deserialized(&self) -> Vec<LoaderData> {
|
||||
let resp = self.get_loaders().await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -77,7 +79,7 @@ impl ApiV3 {
|
||||
loader_field: &str,
|
||||
) -> Vec<LoaderFieldEnumValue> {
|
||||
let resp = self.get_loader_field_variants(loader_field).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -92,7 +94,7 @@ impl ApiV3 {
|
||||
|
||||
pub async fn get_games_deserialized(&self) -> Vec<GameData> {
|
||||
let resp = self.get_games().await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<TeamMember> {
|
||||
let resp = self.get_organization_members(id_or_title, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<TeamMember> {
|
||||
let resp = self.get_team_members(team_id, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<TeamMember> {
|
||||
let resp = self.get_project_members(project_id, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ impl ApiTeams for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<CommonTeamMember> {
|
||||
let resp = self.get_team_members(id_or_title, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Vec<TeamMember> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -103,7 +103,7 @@ impl ApiTeams for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<CommonTeamMember> {
|
||||
let resp = self.get_project_members(id_or_title, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Vec<TeamMember> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -129,7 +129,7 @@ impl ApiTeams for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> Vec<CommonTeamMember> {
|
||||
let resp = self.get_organization_members(id_or_title, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Vec<TeamMember> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
|
||||
@@ -60,7 +60,7 @@ impl ApiV3 {
|
||||
|
||||
pub async fn get_version_deserialized(&self, id: &str, pat: Option<&str>) -> Version {
|
||||
let resp = self.get_version(id, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ impl ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> HashMap<String, Version> {
|
||||
let resp = self.update_individual_files(algorithm, hashes, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ impl ApiVersion for ApiV3 {
|
||||
|
||||
async fn get_version_deserialized_common(&self, id: &str, pat: Option<&str>) -> CommonVersion {
|
||||
let resp = self.get_version(id, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Version = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -217,7 +217,7 @@ impl ApiVersion for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> CommonVersion {
|
||||
let resp = self.get_version_from_hash(hash, algorithm, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Version = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -249,7 +249,7 @@ impl ApiVersion for ApiV3 {
|
||||
pat: Option<&str>,
|
||||
) -> HashMap<String, CommonVersion> {
|
||||
let resp = self.get_versions_from_hashes(hashes, algorithm, pat).await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: HashMap<String, Version> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -301,7 +301,7 @@ impl ApiVersion for ApiV3 {
|
||||
let resp = self
|
||||
.get_update_from_hash(hash, algorithm, loaders, game_versions, version_types, pat)
|
||||
.await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Version = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -361,7 +361,7 @@ impl ApiVersion for ApiV3 {
|
||||
pat,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: HashMap<String, Version> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
@@ -444,7 +444,7 @@ impl ApiVersion for ApiV3 {
|
||||
pat,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(resp.status(), 200);
|
||||
assert_status(&resp, StatusCode::OK);
|
||||
// First, deserialize to the non-common format (to test the response is valid for this api version)
|
||||
let v: Vec<Version> = test::read_body_json(resp).await;
|
||||
// Then, deserialize to the common format
|
||||
|
||||
Reference in New Issue
Block a user