chore: refactor: use api::v1::services and tests::get_ctx

This commit is contained in:
Aravinth Manivannan 2022-09-12 01:39:37 +05:30
parent 94702b81b0
commit e3996134e4
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
3 changed files with 7 additions and 36 deletions

View file

@ -127,7 +127,7 @@ mod tests {
#[actix_rt::test]
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);
let app = get_app!(ctx).await;
let page = ctx.settings.pages.get(0);
@ -157,7 +157,7 @@ mod tests {
#[actix_rt::test]
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);
let page = ctx.settings.pages.get(0);
let page = page.unwrap();

View file

@ -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")]
async fn build_details(ctx: AppCtx) -> impl Responder {
let build = BuildDetails {
@ -82,7 +82,7 @@ mod tests {
#[actix_rt::test]
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);
let app = get_app!(ctx).await;
@ -94,9 +94,8 @@ mod tests {
async fn health_works() {
use actix_web::test;
let settings = Settings::new().unwrap();
let ctx = AppCtx::new(crate::ctx::Ctx::new(settings).await);
let app = test::init_service(App::new().app_data(ctx.clone()).configure(services)).await;
let (_dir, ctx) = tests::get_ctx().await;
let app = get_app!(ctx).await;
let resp = test::call_service(
&app,

View file

@ -14,32 +14,4 @@
* 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/>.
*/
use actix_web::web;
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);
}
pub use crate::api::v1::{routes::ROUTES, services};