Version updates (#3626)

* Update some Labrinth dependencies

* Update some Labrinth dependencies

* Update some Labrinth dependencies

* Update zip in Labrinth

* Update itertools in Labrinth

* Update validator in labrinth

* Update thiserror in labrinth

* Update rust_decimal, redis, and deadpool-redis in labrinth

* Update totp-rs and spdx in labrinth

* Update maxminddb and tar in labrinth

* Update sentry and sentry-actix in labrinth

* Update image in labrinth

* Update lettre in labrinth

* Update derive-new and rust_iso3166 in labrinth

* Update async-stripe and json-patch in labrinth

* Update clap and iana-time-zone in labrinth

* Update labrinth to Rust 2024

* Cargo fmt

* Just do a full cargo update

* Update daedelus to Rust 2024

* Update daedelus_client to Rust 2024

* Set the formatting edition to 2024

* Fix formatting

IntelliJ messed up my formatting
This commit is contained in:
Josiah Glosson
2025-05-09 07:27:55 -05:00
committed by GitHub
parent 6e46317a37
commit 62de07e4e6
146 changed files with 1942 additions and 2311 deletions

View File

@@ -5,12 +5,12 @@ use common::permissions::PermissionsTestContext;
use common::{
api_v3::ApiV3,
database::*,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
};
use itertools::Itertools;
use labrinth::models::teams::ProjectPermissions;
use labrinth::queue::payouts;
use rust_decimal::{prelude::ToPrimitive, Decimal};
use rust_decimal::{Decimal, prelude::ToPrimitive};
mod common;
@@ -89,7 +89,7 @@ pub async fn analytics_revenue() {
assert_eq!(analytics.len(), 1); // 1 project
let project_analytics = analytics.get(&alpha_project_id).unwrap();
assert_eq!(project_analytics.len(), 8); // 1 days cut off, and 2 points take place on the same day. note that the day exactly 14 days ago is included
// sorted_by_key, values in the order of smallest to largest key
// sorted_by_key, values in the order of smallest to largest key
let (sorted_keys, sorted_by_key): (Vec<i64>, Vec<Decimal>) =
project_analytics
.iter()

View File

@@ -10,9 +10,9 @@ use labrinth::models::{
use crate::common::{api_v2::ApiV2, api_v3::ApiV3, dummy_data::TestFile};
use super::{
Api, ApiProject, ApiTags, ApiTeams, ApiUser, ApiVersion,
models::{CommonProject, CommonVersion},
request_data::{ImageData, ProjectCreationRequestData},
Api, ApiProject, ApiTags, ApiTeams, ApiUser, ApiVersion,
};
#[derive(Clone)]

View File

@@ -8,11 +8,11 @@ use self::request_data::{ImageData, ProjectCreationRequestData};
use actix_web::dev::ServiceResponse;
use async_trait::async_trait;
use labrinth::{
LabrinthConfig,
models::{
projects::{ProjectId, VersionType},
teams::{OrganizationPermissions, ProjectPermissions},
},
LabrinthConfig,
};
use super::dummy_data::TestFile;
@@ -169,7 +169,7 @@ pub trait ApiProject {
) -> ServiceResponse;
async fn get_moderation_inbox(&self, pat: Option<&str>) -> ServiceResponse;
async fn read_thread(&self, id: &str, pat: Option<&str>)
-> ServiceResponse;
-> ServiceResponse;
async fn delete_thread_message(
&self,
id: &str,
@@ -340,7 +340,7 @@ pub trait ApiVersion {
pat: Option<&str>,
) -> CommonVersion;
async fn get_version(&self, id: &str, pat: Option<&str>)
-> ServiceResponse;
-> ServiceResponse;
async fn get_version_deserialized_common(
&self,
id_or_slug: &str,

View File

@@ -4,7 +4,7 @@ use super::{
api_common::{Api, ApiBuildable},
environment::LocalService,
};
use actix_web::{dev::ServiceResponse, test, App};
use actix_web::{App, dev::ServiceResponse, test};
use async_trait::async_trait;
use labrinth::LabrinthConfig;
use std::rc::Rc;

View File

@@ -4,9 +4,9 @@ use crate::{
assert_status,
common::{
api_common::{
Api, ApiProject, AppendsOptionalPat,
models::{CommonItemType, CommonProject, CommonVersion},
request_data::{ImageData, ProjectCreationRequestData},
Api, ApiProject, AppendsOptionalPat,
},
dummy_data::TestFile,
},
@@ -27,8 +27,8 @@ use serde_json::json;
use crate::common::database::MOD_USER_PAT;
use super::{
request_data::{self, get_public_project_creation_data},
ApiV2,
request_data::{self, get_public_project_creation_data},
};
impl ApiV2 {

View File

@@ -12,8 +12,8 @@ use crate::{
assert_status,
common::{
api_common::{
models::{CommonCategoryData, CommonLoaderData},
Api, ApiTags, AppendsOptionalPat,
models::{CommonCategoryData, CommonLoaderData},
},
database::ADMIN_USER_PAT,
},

View File

@@ -10,8 +10,8 @@ use serde_json::json;
use crate::{
assert_status,
common::api_common::{
models::{CommonNotification, CommonTeamMember},
Api, ApiTeams, AppendsOptionalPat,
models::{CommonNotification, CommonTeamMember},
},
};

View File

@@ -1,14 +1,14 @@
use std::collections::HashMap;
use super::{
request_data::{self, get_public_version_creation_data},
ApiV2,
request_data::{self, get_public_version_creation_data},
};
use crate::{
assert_status,
common::{
api_common::{
models::CommonVersion, Api, ApiVersion, AppendsOptionalPat,
Api, ApiVersion, AppendsOptionalPat, models::CommonVersion,
},
dummy_data::TestFile,
},

View File

@@ -9,7 +9,7 @@ use serde_json::json;
use crate::{
assert_status,
common::api_common::{request_data::ImageData, Api, AppendsOptionalPat},
common::api_common::{Api, AppendsOptionalPat, request_data::ImageData},
};
use super::ApiV3;

View File

@@ -4,7 +4,7 @@ use super::{
api_common::{Api, ApiBuildable},
environment::LocalService,
};
use actix_web::{dev::ServiceResponse, test, App};
use actix_web::{App, dev::ServiceResponse, test};
use async_trait::async_trait;
use labrinth::LabrinthConfig;
use std::rc::Rc;

View File

@@ -1,6 +1,7 @@
use std::collections::HashMap;
use actix_http::StatusCode;
use actix_web::http::header::{AUTHORIZATION, LOCATION};
use actix_web::{
dev::ServiceResponse,
test::{self, TestRequest},
@@ -9,7 +10,6 @@ use labrinth::auth::oauth::{
OAuthClientAccessRequest, RespondToOAuthClientScopes, TokenRequest,
TokenResponse,
};
use reqwest::header::{AUTHORIZATION, LOCATION};
use crate::{
assert_status,

View File

@@ -11,7 +11,7 @@ use serde_json::json;
use crate::{
assert_status,
common::api_common::{request_data::ImageData, Api, AppendsOptionalPat},
common::api_common::{Api, AppendsOptionalPat, request_data::ImageData},
};
use super::ApiV3;

View File

@@ -20,9 +20,9 @@ use crate::{
assert_status,
common::{
api_common::{
Api, ApiProject, AppendsOptionalPat,
models::{CommonItemType, CommonProject, CommonVersion},
request_data::{ImageData, ProjectCreationRequestData},
Api, ApiProject, AppendsOptionalPat,
},
database::MOD_USER_PAT,
dummy_data::TestFile,
@@ -30,8 +30,8 @@ use crate::{
};
use super::{
request_data::{self, get_public_project_creation_data},
ApiV3,
request_data::{self, get_public_project_creation_data},
};
#[async_trait(?Send)]

View File

@@ -14,8 +14,8 @@ use crate::{
assert_status,
common::{
api_common::{
models::{CommonCategoryData, CommonLoaderData},
Api, ApiTags, AppendsOptionalPat,
models::{CommonCategoryData, CommonLoaderData},
},
database::ADMIN_USER_PAT,
},

View File

@@ -10,8 +10,8 @@ use serde_json::json;
use crate::{
assert_status,
common::api_common::{
models::{CommonNotification, CommonTeamMember},
Api, ApiTeams, AppendsOptionalPat,
models::{CommonNotification, CommonTeamMember},
},
};

View File

@@ -1,14 +1,14 @@
use std::collections::HashMap;
use super::{
request_data::{self, get_public_version_creation_data},
ApiV3,
request_data::{self, get_public_version_creation_data},
};
use crate::{
assert_status,
common::{
api_common::{
models::CommonVersion, Api, ApiVersion, AppendsOptionalPat,
Api, ApiVersion, AppendsOptionalPat, models::CommonVersion,
},
dummy_data::TestFile,
},

View File

@@ -1,7 +1,7 @@
#![allow(dead_code)]
use labrinth::{database::redis::RedisPool, search};
use sqlx::{postgres::PgPoolOptions, PgPool};
use sqlx::{PgPool, postgres::PgPoolOptions};
use std::time::Duration;
use url::Url;
@@ -161,7 +161,9 @@ impl TemporaryDatabase {
let needs_update = dummy_data_update
.is_none_or(|d| d != DUMMY_DATA_UPDATE);
if needs_update {
println!("Dummy data updated, so template DB tables will be dropped and re-created");
println!(
"Dummy data updated, so template DB tables will be dropped and re-created"
);
// Drop all tables in the database so they can be re-created and later filled with updated dummy data
sqlx::query("DROP SCHEMA public CASCADE;")
.execute(&pool)

View File

@@ -11,7 +11,7 @@ use labrinth::models::{
};
use serde_json::json;
use sqlx::Executor;
use zip::{write::FileOptions, CompressionMethod, ZipWriter};
use zip::{CompressionMethod, ZipWriter, write::FileOptions};
use crate::{
assert_status,
@@ -19,7 +19,7 @@ use crate::{
};
use super::{
api_common::{request_data::ImageData, ApiProject, AppendsOptionalPat},
api_common::{ApiProject, AppendsOptionalPat, request_data::ImageData},
api_v3::ApiV3,
database::TemporaryDatabase,
};
@@ -98,7 +98,7 @@ impl TestFile {
let mut zip = ZipWriter::new(&mut cursor);
zip.start_file(
"fabric.mod.json",
FileOptions::default()
FileOptions::<()>::default()
.compression_method(CompressionMethod::Stored),
)
.unwrap();
@@ -106,7 +106,7 @@ impl TestFile {
zip.start_file(
"META-INF/mods.toml",
FileOptions::default()
FileOptions::<()>::default()
.compression_method(CompressionMethod::Stored),
)
.unwrap();
@@ -159,7 +159,7 @@ impl TestFile {
let mut zip = ZipWriter::new(&mut cursor);
zip.start_file(
"modrinth.index.json",
FileOptions::default()
FileOptions::<()>::default()
.compression_method(CompressionMethod::Stored),
)
.unwrap();

View File

@@ -1,10 +1,10 @@
#![allow(dead_code)]
use super::{
api_common::{generic::GenericApi, Api, ApiBuildable},
api_common::{Api, ApiBuildable, generic::GenericApi},
api_v2::ApiV2,
api_v3::ApiV3,
database::{TemporaryDatabase, FRIEND_USER_ID, USER_USER_PAT},
database::{FRIEND_USER_ID, TemporaryDatabase, USER_USER_PAT},
dummy_data,
};
use crate::{assert_status, common::setup};
@@ -146,18 +146,18 @@ pub trait LocalService {
) -> std::pin::Pin<
Box<
dyn std::future::Future<
Output = Result<ServiceResponse, actix_web::Error>,
>,
Output = Result<ServiceResponse, actix_web::Error>,
>,
>,
>;
}
impl<S> LocalService for S
where
S: actix_web::dev::Service<
actix_http::Request,
Response = ServiceResponse,
Error = actix_web::Error,
>,
actix_http::Request,
Response = ServiceResponse,
Error = actix_web::Error,
>,
S::Future: 'static,
{
fn call(
@@ -166,8 +166,8 @@ where
) -> std::pin::Pin<
Box<
dyn std::future::Future<
Output = Result<ServiceResponse, actix_web::Error>,
>,
Output = Result<ServiceResponse, actix_web::Error>,
>,
>,
> {
Box::pin(self.call(req))

View File

@@ -1,5 +1,5 @@
use labrinth::{LabrinthConfig, file_hosting, queue};
use labrinth::{check_env_vars, clickhouse};
use labrinth::{file_hosting, queue, LabrinthConfig};
use std::sync::Arc;
pub mod api_common;

View File

@@ -8,7 +8,7 @@ use serde_json::json;
use crate::common::{
api_common::ApiTeams,
database::{generate_random_name, ADMIN_USER_PAT},
database::{ADMIN_USER_PAT, generate_random_name},
};
use super::{

View File

@@ -10,7 +10,7 @@ use crate::{
common::{
api_common::{Api, ApiProject, ApiVersion},
database::{FRIEND_USER_PAT, MOD_USER_PAT, USER_USER_PAT},
dummy_data::{TestFile, DUMMY_CATEGORIES},
dummy_data::{DUMMY_CATEGORIES, TestFile},
},
};

View File

@@ -5,7 +5,7 @@ use common::api_common::ApiProject;
use common::api_v3::ApiV3;
use common::database::USER_USER_PAT;
use common::environment::{with_test_environment, TestEnvironment};
use common::environment::{TestEnvironment, with_test_environment};
mod common;

View File

@@ -2,7 +2,7 @@
use common::{
api_v3::ApiV3,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
};
mod common;

View File

@@ -3,7 +3,7 @@ use std::collections::HashSet;
use actix_http::StatusCode;
use actix_web::test;
use common::api_v3::ApiV3;
use common::environment::{with_test_environment, TestEnvironment};
use common::environment::{TestEnvironment, with_test_environment};
use itertools::Itertools;
use labrinth::database::models::legacy_loader_fields::MinecraftGameVersion;
use labrinth::models::v3;
@@ -364,16 +364,20 @@ async fn creating_loader_fields() {
project.fields.get("game_versions").unwrap(),
&[json!("1.20.1"), json!("1.20.2"), json!("1.20.5")]
);
assert!(project
.fields
.get("singleplayer")
.unwrap()
.contains(&json!(false)));
assert!(project
.fields
.get("singleplayer")
.unwrap()
.contains(&json!(true)));
assert!(
project
.fields
.get("singleplayer")
.unwrap()
.contains(&json!(false))
);
assert!(
project
.fields
.get("singleplayer")
.unwrap()
.contains(&json!(true))
);
})
.await
}

View File

@@ -1,20 +1,20 @@
use actix_http::StatusCode;
use actix_web::http::header::{CACHE_CONTROL, PRAGMA};
use actix_web::test;
use common::{
api_v3::oauth::get_redirect_location_query_params,
api_v3::{
ApiV3,
oauth::{
get_auth_code_from_redirect_params, get_authorize_accept_flow_id,
},
ApiV3,
},
database::FRIEND_USER_ID,
database::{FRIEND_USER_PAT, USER_USER_ID, USER_USER_PAT},
dummy_data::DummyOAuthClientAlpha,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
};
use labrinth::auth::oauth::TokenResponse;
use reqwest::header::{CACHE_CONTROL, PRAGMA};
mod common;

View File

@@ -4,7 +4,7 @@ use common::{
api_v3::ApiV3,
database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_ID, USER_USER_PAT},
dummy_data::DummyOAuthClientAlpha,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
get_json_val_str,
};
use labrinth::{

View File

@@ -1,9 +1,9 @@
use crate::common::{
api_common::{ApiProject, ApiTeams},
database::{
generate_random_name, ADMIN_USER_PAT, ENEMY_USER_ID_PARSED,
ENEMY_USER_PAT, FRIEND_USER_ID_PARSED, MOD_USER_ID, MOD_USER_PAT,
USER_USER_ID, USER_USER_ID_PARSED,
ADMIN_USER_PAT, ENEMY_USER_ID_PARSED, ENEMY_USER_PAT,
FRIEND_USER_ID_PARSED, MOD_USER_ID, MOD_USER_PAT, USER_USER_ID,
USER_USER_ID_PARSED, generate_random_name,
},
dummy_data::{
DummyImage, DummyOrganizationZeta, DummyProjectAlpha, DummyProjectBeta,
@@ -14,7 +14,7 @@ use common::{
api_v3::ApiV3,
database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_PAT},
environment::{
with_test_environment, with_test_environment_all, TestEnvironment,
TestEnvironment, with_test_environment, with_test_environment_all,
},
permissions::{PermissionsTest, PermissionsTestContext},
};
@@ -372,9 +372,11 @@ async fn add_remove_organization_projects() {
USER_USER_PAT,
)
.await;
assert!(projects
.iter()
.any(|p| p.id.to_string() == alpha_project_id));
assert!(
projects
.iter()
.any(|p| p.id.to_string() == alpha_project_id)
);
// Add/remove project to organization, first by ID, then by slug
for alpha in [alpha_project_id, alpha_project_slug] {
@@ -411,9 +413,11 @@ async fn add_remove_organization_projects() {
USER_USER_PAT,
)
.await;
assert!(!projects
.iter()
.any(|p| p.id.to_string() == alpha_project_id));
assert!(
!projects
.iter()
.any(|p| p.id.to_string() == alpha_project_id)
);
// Remove project from organization
let resp = test_env
@@ -437,9 +441,11 @@ async fn add_remove_organization_projects() {
USER_USER_PAT,
)
.await;
assert!(projects
.iter()
.any(|p| p.id.to_string() == alpha_project_id));
assert!(
projects
.iter()
.any(|p| p.id.to_string() == alpha_project_id)
);
// Get organization projects
let projects = test_env

View File

@@ -4,20 +4,6 @@ use common::api_v3::ApiV3;
use common::database::*;
use common::dummy_data::DUMMY_CATEGORIES;
use ariadne::ids::base62_impl::parse_base62;
use common::environment::{
with_test_environment, with_test_environment_all, TestEnvironment,
};
use common::permissions::{PermissionsTest, PermissionsTestContext};
use futures::StreamExt;
use labrinth::database::models::project_item::{
PROJECTS_NAMESPACE, PROJECTS_SLUGS_NAMESPACE,
};
use labrinth::models::projects::ProjectId;
use labrinth::models::teams::ProjectPermissions;
use labrinth::util::actix::{MultipartSegment, MultipartSegmentData};
use serde_json::json;
use crate::common::api_common::models::CommonProject;
use crate::common::api_common::request_data::ProjectCreationRequestData;
use crate::common::api_common::{ApiProject, ApiTeams, ApiVersion};
@@ -25,6 +11,21 @@ use crate::common::dummy_data::{
DummyImage, DummyOrganizationZeta, DummyProjectAlpha, DummyProjectBeta,
TestFile,
};
use ariadne::ids::base62_impl::parse_base62;
use common::environment::{
TestEnvironment, with_test_environment, with_test_environment_all,
};
use common::permissions::{PermissionsTest, PermissionsTestContext};
use futures::StreamExt;
use hex::ToHex;
use labrinth::database::models::project_item::{
PROJECTS_NAMESPACE, PROJECTS_SLUGS_NAMESPACE,
};
use labrinth::models::projects::ProjectId;
use labrinth::models::teams::ProjectPermissions;
use labrinth::util::actix::{MultipartSegment, MultipartSegmentData};
use serde_json::json;
use sha1::Digest;
mod common;
#[actix_rt::test]
@@ -204,9 +205,8 @@ async fn test_add_remove_project() {
let uploaded_version_id = project.versions[0];
// Checks files to ensure they were uploaded and correctly identify the file
let hash = sha1::Sha1::from(basic_mod_file.bytes())
.digest()
.to_string();
let hash = sha1::Sha1::digest(basic_mod_file.bytes())
.encode_hex::<String>();
let version = api
.get_version_from_hash_deserialized_common(
&hash,

View File

@@ -10,13 +10,13 @@ use actix_http::StatusCode;
use actix_web::test;
use ariadne::ids::base62_impl::parse_base62;
use chrono::{Duration, Utc};
use common::api_common::models::CommonItemType;
use common::api_common::Api;
use common::api_v3::request_data::get_public_project_creation_data;
use common::api_common::models::CommonItemType;
use common::api_v3::ApiV3;
use common::api_v3::request_data::get_public_project_creation_data;
use common::dummy_data::TestFile;
use common::environment::{
with_test_environment, with_test_environment_all, TestEnvironment,
TestEnvironment, with_test_environment, with_test_environment_all,
};
use common::{database::*, scopes::ScopeTest};
use labrinth::models::pats::Scopes;
@@ -380,16 +380,20 @@ pub async fn project_version_reads_scopes() {
.test(req_gen, read_project)
.await
.unwrap();
assert!(!failure
.as_array()
.unwrap()
.iter()
.any(|x| x["status"] == "processing"));
assert!(success
.as_array()
.unwrap()
.iter()
.any(|x| x["status"] == "processing"));
assert!(
!failure
.as_array()
.unwrap()
.iter()
.any(|x| x["status"] == "processing")
);
assert!(
success
.as_array()
.unwrap()
.iter()
.any(|x| x["status"] == "processing")
);
// Project metadata reading
let req_gen = |pat: Option<String>| async move {

View File

@@ -5,8 +5,8 @@ use common::database::*;
use common::dummy_data::DUMMY_CATEGORIES;
use ariadne::ids::base62_impl::parse_base62;
use common::environment::with_test_environment;
use common::environment::TestEnvironment;
use common::environment::with_test_environment;
use common::search::setup_search_projects;
use futures::stream::StreamExt;
use serde_json::json;

View File

@@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
use common::{
api_v3::ApiV3,
environment::{
with_test_environment, with_test_environment_all, TestEnvironment,
TestEnvironment, with_test_environment, with_test_environment_all,
},
};

View File

@@ -3,7 +3,7 @@ use actix_http::StatusCode;
use common::{
api_v3::ApiV3,
environment::{
with_test_environment, with_test_environment_all, TestEnvironment,
TestEnvironment, with_test_environment, with_test_environment_all,
},
};
use labrinth::models::teams::{OrganizationPermissions, ProjectPermissions};

View File

@@ -94,9 +94,11 @@ pub async fn get_user_projects_after_joining_team_shows_team_projects() {
FRIEND_USER_PAT,
)
.await;
assert!(projects
.iter()
.any(|p| p.id.to_string() == *alpha_project_id));
assert!(
projects
.iter()
.any(|p| p.id.to_string() == *alpha_project_id)
);
})
.await;
}
@@ -131,9 +133,11 @@ pub async fn get_user_projects_after_leaving_team_shows_no_team_projects() {
FRIEND_USER_PAT,
)
.await;
assert!(!projects
.iter()
.any(|p| p.id.to_string() == *alpha_project_id));
assert!(
!projects
.iter()
.any(|p| p.id.to_string() == *alpha_project_id)
);
})
.await;
}

View File

@@ -8,7 +8,7 @@ use bytes::Bytes;
use crate::common::database::USER_USER_PAT;
use crate::common::{
api_v2::ApiV2,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
};
#[actix_rt::test]
pub async fn error_404_empty() {

View File

@@ -2,7 +2,7 @@ use crate::common::{
api_common::ApiTeams,
api_v2::ApiV2,
database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_PAT},
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
};
#[actix_rt::test]

View File

@@ -4,13 +4,13 @@ use crate::{
assert_status,
common::{
api_common::{ApiProject, ApiVersion, AppendsOptionalPat},
api_v2::{request_data::get_public_project_creation_data_json, ApiV2},
api_v2::{ApiV2, request_data::get_public_project_creation_data_json},
database::{
generate_random_name, ADMIN_USER_PAT, FRIEND_USER_ID,
FRIEND_USER_PAT, USER_USER_PAT,
ADMIN_USER_PAT, FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_PAT,
generate_random_name,
},
dummy_data::TestFile,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
permissions::{PermissionsTest, PermissionsTestContext},
},
};
@@ -18,6 +18,7 @@ use actix_http::StatusCode;
use actix_web::test;
use ariadne::ids::base62_impl::parse_base62;
use futures::StreamExt;
use hex::ToHex;
use itertools::Itertools;
use labrinth::{
database::models::project_item::PROJECTS_SLUGS_NAMESPACE,
@@ -25,6 +26,7 @@ use labrinth::{
util::actix::{AppendsMultipart, MultipartSegment, MultipartSegmentData},
};
use serde_json::json;
use sha1::Digest;
#[actix_rt::test]
async fn test_project_type_sanity() {
@@ -202,9 +204,8 @@ async fn test_add_remove_project() {
let uploaded_version_id = project.versions[0];
// Checks files to ensure they were uploaded and correctly identify the file
let hash = sha1::Sha1::from(basic_mod_file.bytes())
.digest()
.to_string();
let hash = sha1::Sha1::digest(basic_mod_file.bytes())
.encode_hex::<String>();
let version = api
.get_version_from_hash_deserialized(
&hash,
@@ -468,7 +469,7 @@ async fn permissions_patch_project_v2() {
.map(|(key, value)| {
let test_env = test_env.clone();
async move {
let req_gen = |ctx: PermissionsTestContext| async {
let req_gen = async |ctx: PermissionsTestContext| {
api.edit_project(
&ctx.project_id.unwrap(),
json!({

View File

@@ -1,10 +1,10 @@
use crate::common::api_common::ApiProject;
use crate::common::api_common::ApiVersion;
use crate::common::api_v2::request_data::get_public_project_creation_data;
use crate::common::api_v2::ApiV2;
use crate::common::api_v2::request_data::get_public_project_creation_data;
use crate::common::dummy_data::TestFile;
use crate::common::environment::with_test_environment;
use crate::common::environment::TestEnvironment;
use crate::common::environment::with_test_environment;
use crate::common::scopes::ScopeTest;
use ariadne::ids::base62_impl::parse_base62;
use labrinth::models::pats::Scopes;

View File

@@ -5,10 +5,10 @@ use crate::common::api_common::ApiVersion;
use crate::common::api_v2::ApiV2;
use crate::common::database::*;
use crate::common::dummy_data::TestFile;
use crate::common::dummy_data::DUMMY_CATEGORIES;
use crate::common::environment::with_test_environment;
use crate::common::dummy_data::TestFile;
use crate::common::environment::TestEnvironment;
use crate::common::environment::with_test_environment;
use actix_http::StatusCode;
use ariadne::ids::base62_impl::parse_base62;
use futures::stream::StreamExt;

View File

@@ -5,7 +5,7 @@ use std::collections::HashSet;
use crate::common::{
api_v2::ApiV2,
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
};
#[actix_rt::test]

View File

@@ -11,7 +11,7 @@ use crate::{
FRIEND_USER_ID, FRIEND_USER_ID_PARSED, FRIEND_USER_PAT,
USER_USER_ID_PARSED, USER_USER_PAT,
},
environment::{with_test_environment, TestEnvironment},
environment::{TestEnvironment, with_test_environment},
},
};

View File

@@ -14,7 +14,7 @@ use crate::common::api_v2::ApiV2;
use crate::common::api_v2::request_data::get_public_project_creation_data;
use crate::common::dummy_data::{DummyProjectAlpha, DummyProjectBeta};
use crate::common::environment::{with_test_environment, TestEnvironment};
use crate::common::environment::{TestEnvironment, with_test_environment};
use crate::common::{
database::{ENEMY_USER_PAT, USER_USER_PAT},
dummy_data::TestFile,
@@ -470,10 +470,10 @@ async fn add_version_project_types_v2() {
)
.await;
assert_eq!(test_project.project_type, "project"); // No project_type set, as no versions are set
// Default to 'project' if none are found
// This is a known difference between older v2 ,but is acceptable.
// This would be the appropriate test on older v2:
// assert_eq!(test_project.project_type, "modpack");
// Default to 'project' if none are found
// This is a known difference between older v2 ,but is acceptable.
// This would be the appropriate test on older v2:
// assert_eq!(test_project.project_type, "modpack");
// Create a version with a modpack file attached
let test_version = api