changes tests to a macro (#822)

This commit is contained in:
Wyatt Verchere
2024-01-06 11:08:03 -08:00
committed by GitHub
parent 10eed05d87
commit 87862f3e23
32 changed files with 423 additions and 391 deletions

View File

@@ -6,7 +6,6 @@ use common::environment::{with_test_environment, TestEnvironment};
use serde_json::json;
use crate::common::api_common::ApiVersion;
use crate::common::asserts::assert_status;
use crate::common::database::*;
use crate::common::dummy_data::{DummyProjectAlpha, DummyProjectBeta, TestFile};
@@ -51,7 +50,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// - Patch
let resp = api
.edit_version(
@@ -62,7 +61,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// Cannot create a version with a loader field that isnt used by the loader
// TODO: - Create project
@@ -84,7 +83,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// - Patch
let resp = api
.edit_version(
@@ -95,7 +94,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// Cannot create a version without an applicable loader field that is not optional
// TODO: - Create project
@@ -117,7 +116,7 @@ async fn creating_loader_fields() {
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// Cannot create a version without a loader field array that has a minimum of 1
// TODO: - Create project
@@ -138,7 +137,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// TODO: Create a test for too many elements in the array when we have a LF that has a max (past max)
// Cannot create a version with a loader field array that has fewer than the minimum elements
@@ -161,7 +160,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// - Patch
let resp = api
@@ -173,7 +172,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// Cannot create an invalid data type for the loader field type (including bad variant for the type)
for bad_type_game_versions in [
@@ -201,7 +200,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
// - Patch
let resp = api
@@ -213,7 +212,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::BAD_REQUEST);
assert_status!(&resp, StatusCode::BAD_REQUEST);
}
// Can create with optional loader fields (other tests have checked if we can create without them)
@@ -247,7 +246,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::NO_CONTENT);
assert_status!(&resp, StatusCode::NO_CONTENT);
let v = api
.get_version_deserialized(alpha_version_id, USER_USER_PAT)
.await;
@@ -298,7 +297,7 @@ async fn creating_loader_fields() {
USER_USER_PAT,
)
.await;
assert_status(&resp, StatusCode::NO_CONTENT);
assert_status!(&resp, StatusCode::NO_CONTENT);
let v = api
.get_version_deserialized(alpha_version_id, USER_USER_PAT)
.await;