You've already forked AstralRinth
forked from didirus/AstralRinth
Expose test utils to Labrinth dependents (#4703)
* Expose test utils to Labrinth dependents * Feature gate `labrinth::test` * Unify db migrators * Expose `NotificationBuilder::insert_many_deliveries` * Add logging utils to common crate * Remove unused console-subscriber layer * fix CI
This commit is contained in:
44
apps/labrinth/src/test/api_v3/limits.rs
Normal file
44
apps/labrinth/src/test/api_v3/limits.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use crate::models::v3::user_limits::UserLimits;
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::test;
|
||||
|
||||
use crate::test::asserts::assert_status;
|
||||
use crate::test::{
|
||||
api_common::{Api, AppendsOptionalPat},
|
||||
api_v3::ApiV3,
|
||||
};
|
||||
|
||||
impl ApiV3 {
|
||||
pub async fn get_project_limits(&self, pat: Option<&str>) -> UserLimits {
|
||||
let req = test::TestRequest::get()
|
||||
.uri("/v3/limits/projects")
|
||||
.append_pat(pat)
|
||||
.to_request();
|
||||
let resp = self.call(req).await;
|
||||
assert_status!(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
pub async fn get_organization_limits(
|
||||
&self,
|
||||
pat: Option<&str>,
|
||||
) -> UserLimits {
|
||||
let req = test::TestRequest::get()
|
||||
.uri("/v3/limits/organizations")
|
||||
.append_pat(pat)
|
||||
.to_request();
|
||||
let resp = self.call(req).await;
|
||||
assert_status!(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
|
||||
pub async fn get_collection_limits(&self, pat: Option<&str>) -> UserLimits {
|
||||
let req = test::TestRequest::get()
|
||||
.uri("/v3/limits/collections")
|
||||
.append_pat(pat)
|
||||
.to_request();
|
||||
let resp = self.call(req).await;
|
||||
assert_status!(&resp, StatusCode::OK);
|
||||
test::read_body_json(resp).await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user