1
0

Cleans up and removes TODOs, adds tests (#844)

* removes version ordering from v2; simplifies now-unecessary three-level faceting

* resolved some todos

* test for game version updating

* merge fixes; display_categories fix
This commit is contained in:
Wyatt Verchere
2024-01-11 18:11:27 -08:00
committed by GitHub
parent 76c885f080
commit ef31c0c0da
24 changed files with 243 additions and 241 deletions

View File

@@ -15,9 +15,8 @@ use zip::{write::FileOptions, CompressionMethod, ZipWriter};
use crate::{
assert_status,
common::{api_common::Api, database::USER_USER_PAT},
common::{api_common::Api, api_v3, database::USER_USER_PAT},
};
use labrinth::util::actix::{AppendsMultipart, MultipartSegment, MultipartSegmentData};
use super::{
api_common::{request_data::ImageData, ApiProject, AppendsOptionalPat},
@@ -342,58 +341,22 @@ pub async fn add_project_beta(api: &ApiV3) -> (Project, Version) {
// Generate test project data.
let jar = TestFile::DummyProjectBeta;
// TODO: this shouldnt be hardcoded (nor should other similar ones be)
let json_data = json!(
{
"name": "Test Project Beta",
"slug": "beta",
"summary": "A dummy project for testing with.",
"description": "This project is not-yet-approved, and versions are draft.",
"initial_versions": [{
"file_parts": [jar.filename()],
"version_number": "1.2.3",
"version_title": "start",
"status": "unlisted",
"dependencies": [],
"singleplayer": true,
"client_and_server": true,
"client_only": true,
"server_only": false,
"game_versions": ["1.20.1"] ,
"release_channel": "release",
"loaders": ["fabric"],
"featured": true
}],
"status": "private",
"requested_status": "private",
"categories": [],
"license_id": "MIT"
}
let modify_json = serde_json::from_value(json!([
{ "op": "add", "path": "/summary", "value": "A dummy project for testing with." },
{ "op": "add", "path": "/description", "value": "This project is not-yet-approved, and versions are draft." },
{ "op": "add", "path": "/initial_versions/0/status", "value": "unlisted" },
{ "op": "add", "path": "/status", "value": "private" },
{ "op": "add", "path": "/requested_status", "value": "private" },
]))
.unwrap();
let creation_data = api_v3::request_data::get_public_project_creation_data(
"beta",
Some(jar),
Some(modify_json),
);
// Basic json
let json_segment = MultipartSegment {
name: "data".to_string(),
filename: None,
content_type: Some("application/json".to_string()),
data: MultipartSegmentData::Text(serde_json::to_string(&json_data).unwrap()),
};
// Basic file
let file_segment = MultipartSegment {
name: jar.filename(),
filename: Some(jar.filename()),
content_type: Some("application/java-archive".to_string()),
data: MultipartSegmentData::Binary(jar.bytes()),
};
// Add a project.
let req = TestRequest::post()
.uri("/v3/project")
.append_pat(USER_USER_PAT)
.set_multipart(vec![json_segment.clone(), file_segment.clone()])
.to_request();
let resp = api.call(req).await;
assert_status!(&resp, StatusCode::OK);
api.create_project(creation_data, USER_USER_PAT).await;
get_project_beta(api).await
}