Skip to content

Commit

Permalink
init launch-app
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad committed Sep 19, 2024
1 parent a064f78 commit 306fe36
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 177 deletions.
2 changes: 1 addition & 1 deletion examples/playground.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use launch_app::app::App;
#[allow(unused_imports)]
use loco_rs::{cli::playground, prelude::*};
use launch_app::app::App;

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
Expand Down
3 changes: 0 additions & 3 deletions migration/src/m20240917_065557_contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,4 @@ enum Contacts {
Table,
Id,
Email,

}


2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use loco_rs::cli;
use launch_app::app::App;
use loco_rs::cli;
use migration::Migrator;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use loco_rs::cli;
use launch_app::app::App;
use loco_rs::cli;
use migration::Migrator;

#[tokio::main]
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/pages.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::unnecessary_struct_initialization)]
#![allow(clippy::unused_async)]
use loco_rs::prelude::*;
use axum::debug_handler;
use loco_rs::prelude::*;

#[debug_handler]
pub async fn about(
ViewEngine(v): ViewEngine<TeraView>,
State(_ctx): State<AppContext>
State(_ctx): State<AppContext>,
) -> Result<Response> {
format::render().view(&v, "pages/about.html", serde_json::json!({}))
}

#[debug_handler]
pub async fn terms(
ViewEngine(v): ViewEngine<TeraView>,
State(_ctx): State<AppContext>
State(_ctx): State<AppContext>,
) -> Result<Response> {
format::render().view(&v, "pages/terms.html", serde_json::json!({}))
}
Expand Down
4 changes: 4 additions & 0 deletions src/models/contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ impl ActiveModelBehavior for ActiveModel {
}

impl Model {
/// Check if contact user exists by email
///
/// # Errors
/// When could has query/connectivity error
pub async fn exists(db: &DatabaseConnection, email: &str) -> ModelResult<bool> {
let count = contacts::Entity::find()
.filter(
Expand Down
2 changes: 1 addition & 1 deletion src/views/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod auth;
pub mod user;

pub mod contacts;
pub mod contacts;
2 changes: 1 addition & 1 deletion tests/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod users;

mod contacts;
mod contacts;
2 changes: 1 addition & 1 deletion tests/models/users.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use insta::assert_debug_snapshot;
use loco_rs::{model::ModelError, testing};
use launch_app::{
app::App,
models::users::{self, Model, RegisterParams},
};
use loco_rs::{model::ModelError, testing};
use sea_orm::{ActiveModelTrait, ActiveValue, IntoActiveModel};
use serial_test::serial;

Expand Down
2 changes: 1 addition & 1 deletion tests/requests/auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing;
use launch_app::{app::App, models::users};
use loco_rs::testing;
use rstest::rstest;
use serial_test::serial;

Expand Down
1 change: 0 additions & 1 deletion tests/requests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod auth;
mod notes;
mod prepare_data;
mod user;
123 changes: 0 additions & 123 deletions tests/requests/notes.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/requests/prepare_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum::http::{HeaderName, HeaderValue};
use loco_rs::{app::AppContext, TestServer};
use launch_app::{models::users, views::auth::LoginResponse};
use loco_rs::{app::AppContext, TestServer};

const USER_EMAIL: &str = "[email protected]";
const USER_PASSWORD: &str = "1234";
Expand Down
8 changes: 0 additions & 8 deletions tests/requests/snapshots/can_add_note@notes_request.snap

This file was deleted.

8 changes: 0 additions & 8 deletions tests/requests/snapshots/can_delete_note@notes_request.snap

This file was deleted.

8 changes: 0 additions & 8 deletions tests/requests/snapshots/can_get_note@notes_request.snap

This file was deleted.

8 changes: 0 additions & 8 deletions tests/requests/snapshots/can_get_notes@notes_request.snap

This file was deleted.

2 changes: 1 addition & 1 deletion tests/requests/user.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing;
use launch_app::app::App;
use loco_rs::testing;
use serial_test::serial;

use super::prepare_data;
Expand Down
12 changes: 7 additions & 5 deletions tests/tasks/list_contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ use serial_test::serial;
async fn test_can_run_list_users() {
let boot = testing::boot_test::<App>().await.unwrap();

assert!(
run_task::<App>(&boot.app_context, Some(&"list_users".to_string()), &task::Vars::default())
.await
.is_ok()
);
assert!(run_task::<App>(
&boot.app_context,
Some(&"list_users".to_string()),
&task::Vars::default()
)
.await
.is_ok());
}
2 changes: 1 addition & 1 deletion tests/tasks/seed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use loco_rs::{boot::run_task, task, testing};
use launch_app::app::App;
use loco_rs::{boot::run_task, task, testing};
use serial_test::serial;

#[tokio::test]
Expand Down

0 comments on commit 306fe36

Please sign in to comment.