You've already forked AstralRinth
forked from didirus/AstralRinth
Fixes incorrect loader fields (#849)
* loader_fields fix * tested, fixed * added direct file check for invalid file_parts * search fixes * removed printlns * Adds check for loaders * removes println
This commit is contained in:
@@ -170,8 +170,9 @@ async fn search_projects() {
|
||||
));
|
||||
|
||||
// Test project 7 (testing the search bug)
|
||||
// This project has an initial private forge version that is 1.20.3, and a fabric 1.20.5 version.
|
||||
// This means that a search for fabric + 1.20.3 or forge + 1.20.5 should not return this project.
|
||||
// This project has an initial private forge version that is 1.20.2, and a fabric 1.20.1 version.
|
||||
// This means that a search for fabric + 1.20.1 or forge + 1.20.1 should not return this project,
|
||||
// but a search for fabric + 1.20.1 should, and it should include both versions in the data.
|
||||
let id = 7;
|
||||
let modify_json = serde_json::from_value(json!([
|
||||
{ "op": "add", "path": "/categories", "value": DUMMY_CATEGORIES[5..6] },
|
||||
@@ -231,15 +232,6 @@ async fn search_projects() {
|
||||
// 1. vec of search facets
|
||||
// 2. expected project ids to be returned by this search
|
||||
let pairs = vec![
|
||||
// For testing: remove me
|
||||
(
|
||||
json!([
|
||||
["client_side:required"],
|
||||
["versions:1.20.5"],
|
||||
[&format!("categories:{}", DUMMY_CATEGORIES[5])]
|
||||
]),
|
||||
vec![],
|
||||
),
|
||||
(
|
||||
json!([["categories:fabric"]]),
|
||||
vec![0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||
@@ -277,6 +269,14 @@ async fn search_projects() {
|
||||
]),
|
||||
vec![],
|
||||
),
|
||||
(
|
||||
json!([
|
||||
// But it does have a 1.20.2 forge version, so this should return it.
|
||||
["categories:forge"],
|
||||
["versions:1.20.2"]
|
||||
]),
|
||||
vec![7],
|
||||
),
|
||||
// Project type change
|
||||
// Modpack should still be able to search based on former loader, even though technically the loader is 'mrpack'
|
||||
// (json!([["categories:mrpack"]]), vec![4]),
|
||||
@@ -382,15 +382,25 @@ async fn search_projects() {
|
||||
assert_eq!(hit.server_side, "optional".to_string());
|
||||
}
|
||||
|
||||
// Ensure game_versions return correctly, but also correctly aggregated
|
||||
// over all versions of a project
|
||||
let game_versions = api
|
||||
.search_deserialized(
|
||||
Some(&format!("\"&{test_name}\"")),
|
||||
Some(json!([["versions:1.20.5"]])),
|
||||
Some(json!([["categories:forge"], ["versions:1.20.2"]])),
|
||||
USER_USER_PAT,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(game_versions.hits.len(), 1);
|
||||
for hit in game_versions.hits {
|
||||
assert_eq!(hit.versions, vec!["1.20.5".to_string()]);
|
||||
assert_eq!(
|
||||
hit.versions,
|
||||
vec!["1.20.1".to_string(), "1.20.2".to_string()]
|
||||
);
|
||||
assert!(hit.categories.contains(&"forge".to_string()));
|
||||
assert!(hit.categories.contains(&"fabric".to_string()));
|
||||
|
||||
// Also, ensure author is correctly capitalized
|
||||
assert_eq!(hit.author, "User".to_string());
|
||||
}
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::assert_status;
|
||||
use crate::common::api_common::{ApiProject, ApiVersion};
|
||||
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::{
|
||||
@@ -469,3 +470,48 @@ async fn add_version_project_types_v2() {
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_incorrect_file_parts() {
|
||||
// Ensures that a version get that 'should' have mrpack_loaders does still display them
|
||||
// if the file is 'mrpack' but the file_parts are incorrect
|
||||
with_test_environment(None, |test_env: TestEnvironment<ApiV2>| async move {
|
||||
let api = &test_env.api;
|
||||
|
||||
// Patch to set the file_parts to something incorrect
|
||||
let patch = json!([{
|
||||
"op": "add",
|
||||
"path": "/file_parts",
|
||||
"value": ["invalid.zip"] // one file, wrong non-mrpack extension
|
||||
}]);
|
||||
|
||||
// Create an empty project
|
||||
let slug = "test-project";
|
||||
let creation_data = get_public_project_creation_data(slug, None, None);
|
||||
let resp = api.create_project(creation_data, USER_USER_PAT).await;
|
||||
assert_status!(&resp, StatusCode::OK);
|
||||
|
||||
// Get the project
|
||||
let project = api.get_project_deserialized(slug, USER_USER_PAT).await;
|
||||
assert_eq!(project.project_type, "project");
|
||||
|
||||
// Create a version with a mrpack file, but incorrect file_parts
|
||||
let resp = api
|
||||
.add_public_version(
|
||||
project.id,
|
||||
"1.0.0",
|
||||
TestFile::build_random_mrpack(),
|
||||
None,
|
||||
Some(serde_json::from_value(patch).unwrap()),
|
||||
USER_USER_PAT,
|
||||
)
|
||||
.await;
|
||||
assert_status!(&resp, StatusCode::OK);
|
||||
|
||||
// Get the project now, which should be now correctly identified as a modpack
|
||||
let project = api.get_project_deserialized(slug, USER_USER_PAT).await;
|
||||
assert_eq!(project.project_type, "modpack");
|
||||
assert_eq!(project.loaders, vec!["fabric"]);
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user