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

@@ -7,12 +7,12 @@ use labrinth::models::{
};
use serde_json::json;
use crate::common::{
api_common::{
use crate::{
assert_status,
common::api_common::{
models::{CommonNotification, CommonTeamMember},
Api, ApiTeams, AppendsOptionalPat,
},
asserts::assert_status,
};
use super::ApiV2;
@@ -24,7 +24,7 @@ impl ApiV2 {
pat: Option<&str>,
) -> Vec<LegacyTeamMember> {
let resp = self.get_organization_members(id_or_title, pat).await;
assert_status(&resp, StatusCode::OK);
assert_status!(&resp, StatusCode::OK);
test::read_body_json(resp).await
}
@@ -34,7 +34,7 @@ impl ApiV2 {
pat: Option<&str>,
) -> Vec<LegacyTeamMember> {
let resp = self.get_team_members(team_id, pat).await;
assert_status(&resp, StatusCode::OK);
assert_status!(&resp, StatusCode::OK);
test::read_body_json(resp).await
}
@@ -44,7 +44,7 @@ impl ApiV2 {
pat: Option<&str>,
) -> Vec<LegacyNotification> {
let resp = self.get_user_notifications(user_id, pat).await;
assert_status(&resp, StatusCode::OK);
assert_status!(&resp, StatusCode::OK);
test::read_body_json(resp).await
}
}
@@ -65,7 +65,7 @@ impl ApiTeams for ApiV2 {
pat: Option<&str>,
) -> Vec<CommonTeamMember> {
let resp = self.get_team_members(id_or_title, pat).await;
assert_status(&resp, StatusCode::OK);
assert_status!(&resp, StatusCode::OK);
// TODO: Note, this does NOT deserialize to any other struct first, as currently TeamMember is the same in v2 and v3.
// CommonTeamMember = TeamMember (v3)
// This may yet change, so we should keep common struct.
@@ -102,7 +102,7 @@ impl ApiTeams for ApiV2 {
pat: Option<&str>,
) -> Vec<CommonTeamMember> {
let resp = self.get_project_members(id_or_title, pat).await;
assert_status(&resp, StatusCode::OK);
assert_status!(&resp, StatusCode::OK);
// TODO: Note, this does NOT deserialize to any other struct first, as currently TeamMember is the same in v2 and v3.
// CommonTeamMember = TeamMember (v3)
// This may yet change, so we should keep common struct.
@@ -127,7 +127,7 @@ impl ApiTeams for ApiV2 {
pat: Option<&str>,
) -> Vec<CommonTeamMember> {
let resp = self.get_organization_members(id_or_title, pat).await;
assert_status(&resp, StatusCode::OK);
assert_status!(&resp, StatusCode::OK);
// TODO: Note, this does NOT deserialize to any other struct first, as currently TeamMember is the same in v2 and v3.
// CommonTeamMember = TeamMember (v3)
// This may yet change, so we should keep common struct.
@@ -200,7 +200,7 @@ impl ApiTeams for ApiV2 {
pat: Option<&str>,
) -> Vec<CommonNotification> {
let resp = self.get_user_notifications(user_id, pat).await;
assert_status(&resp, StatusCode::OK);
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<LegacyNotification> = test::read_body_json(resp).await;
// Then, deserialize to the common format