chore: refactor: use api::v1::services and tests::get_ctx
This commit is contained in:
parent
94702b81b0
commit
e3996134e4
3 changed files with 7 additions and 36 deletions
|
@ -127,7 +127,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn deploy_update_works() {
|
async fn deploy_update_works() {
|
||||||
let (_dir, ctx) = tests::get_data().await;
|
let (_dir, ctx) = tests::get_ctx().await;
|
||||||
println!("[log] test configuration {:#?}", ctx.settings);
|
println!("[log] test configuration {:#?}", ctx.settings);
|
||||||
let app = get_app!(ctx).await;
|
let app = get_app!(ctx).await;
|
||||||
let page = ctx.settings.pages.get(0);
|
let page = ctx.settings.pages.get(0);
|
||||||
|
@ -157,7 +157,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn deploy_info_works() {
|
async fn deploy_info_works() {
|
||||||
let (_dir, ctx) = tests::get_data().await;
|
let (_dir, ctx) = tests::get_ctx().await;
|
||||||
println!("[log] test configuration {:#?}", ctx.settings);
|
println!("[log] test configuration {:#?}", ctx.settings);
|
||||||
let page = ctx.settings.pages.get(0);
|
let page = ctx.settings.pages.get(0);
|
||||||
let page = page.unwrap();
|
let page = page.unwrap();
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub mod routes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emmits build details of the bninary
|
/// emits build details of the binary
|
||||||
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.meta.build_details")]
|
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.meta.build_details")]
|
||||||
async fn build_details(ctx: AppCtx) -> impl Responder {
|
async fn build_details(ctx: AppCtx) -> impl Responder {
|
||||||
let build = BuildDetails {
|
let build = BuildDetails {
|
||||||
|
@ -82,7 +82,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn build_details_works() {
|
async fn build_details_works() {
|
||||||
let (_dir, ctx) = tests::get_data().await;
|
let (_dir, ctx) = tests::get_ctx().await;
|
||||||
println!("[log] test configuration {:#?}", ctx.settings);
|
println!("[log] test configuration {:#?}", ctx.settings);
|
||||||
let app = get_app!(ctx).await;
|
let app = get_app!(ctx).await;
|
||||||
|
|
||||||
|
@ -94,9 +94,8 @@ mod tests {
|
||||||
async fn health_works() {
|
async fn health_works() {
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
|
||||||
let settings = Settings::new().unwrap();
|
let (_dir, ctx) = tests::get_ctx().await;
|
||||||
let ctx = AppCtx::new(crate::ctx::Ctx::new(settings).await);
|
let app = get_app!(ctx).await;
|
||||||
let app = test::init_service(App::new().app_data(ctx.clone()).configure(services)).await;
|
|
||||||
|
|
||||||
let resp = test::call_service(
|
let resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
|
|
|
@ -14,32 +14,4 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use actix_web::web;
|
pub use crate::api::v1::{routes::ROUTES, services};
|
||||||
|
|
||||||
use crate::deploy::routes::Deploy;
|
|
||||||
use crate::meta::routes::Meta;
|
|
||||||
use crate::serve::routes::Serve;
|
|
||||||
|
|
||||||
pub const ROUTES: Routes = Routes::new();
|
|
||||||
|
|
||||||
pub struct Routes {
|
|
||||||
pub meta: Meta,
|
|
||||||
pub deploy: Deploy,
|
|
||||||
pub serve: Serve,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Routes {
|
|
||||||
pub const fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
meta: Meta::new(),
|
|
||||||
deploy: Deploy::new(),
|
|
||||||
serve: Serve::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
|
||||||
crate::meta::services(cfg);
|
|
||||||
crate::deploy::services(cfg);
|
|
||||||
crate::serve::services(cfg);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue