feat: add basic webui
This commit is contained in:
3
apps/recorder/tests/mod.rs
Normal file
3
apps/recorder/tests/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
mod models;
|
||||
mod requests;
|
||||
mod tasks;
|
||||
1
apps/recorder/tests/models/mod.rs
Normal file
1
apps/recorder/tests/models/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod subscribers;
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/models/subscribers.rs
|
||||
expression: non_existing_subscriber_results
|
||||
---
|
||||
Err(
|
||||
EntityNotFound,
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
source: tests/models/subscribers.rs
|
||||
expression: existing_subscriber
|
||||
---
|
||||
Ok(
|
||||
Model {
|
||||
created_at: 2023-11-12T12:34:56.789,
|
||||
updated_at: 2023-11-12T12:34:56.789,
|
||||
id: 1,
|
||||
pid: "11111111-1111-1111-1111-111111111111",
|
||||
display_name: "user1"
|
||||
},
|
||||
)
|
||||
27
apps/recorder/tests/models/subscribers.rs
Normal file
27
apps/recorder/tests/models/subscribers.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use insta::assert_debug_snapshot;
|
||||
use loco_rs::testing;
|
||||
use recorder::{app::App, models::subscribers::Model};
|
||||
use serial_test::serial;
|
||||
|
||||
macro_rules! configure_insta {
|
||||
($($expr:expr),*) => {
|
||||
let mut settings = insta::Settings::clone_current();
|
||||
settings.set_prepend_module_to_snapshot(false);
|
||||
settings.set_snapshot_suffix("users");
|
||||
let _guard = settings.bind_to_scope();
|
||||
};
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn can_find_by_pid() {
|
||||
// configure_insta!();
|
||||
//
|
||||
// let boot = testing::boot_test::<App>().await.unwrap();
|
||||
// testing::seed::<App>(&boot.app_context.db).await.unwrap();
|
||||
//
|
||||
// let existing_subscriber =
|
||||
// Model::find_by_pid(&boot.app_context, "11111111-1111-1111-1111-111111111111").await;
|
||||
//
|
||||
// assert_debug_snapshot!(existing_subscriber);
|
||||
}
|
||||
1
apps/recorder/tests/requests/mod.rs
Normal file
1
apps/recorder/tests/requests/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod subscribers;
|
||||
33
apps/recorder/tests/requests/subscribers.rs
Normal file
33
apps/recorder/tests/requests/subscribers.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
#![allow(unused_imports)]
|
||||
use insta::{assert_debug_snapshot, with_settings};
|
||||
use loco_rs::testing;
|
||||
use recorder::app::App;
|
||||
use serial_test::serial;
|
||||
|
||||
// TODO: see how to dedup / extract this to app-local test utils
|
||||
// not to framework, because that would require a runtime dep on insta
|
||||
// macro_rules! configure_insta {
|
||||
// ($($expr:expr),*) => {
|
||||
// let mut settings = insta::Settings::clone_current();
|
||||
// settings.set_prepend_module_to_snapshot(false);
|
||||
// settings.set_snapshot_suffix("user_request");
|
||||
// let _guard = settings.bind_to_scope();
|
||||
// };
|
||||
// }
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn can_get_current_user() {
|
||||
// configure_insta!();
|
||||
//
|
||||
// testing::request::<App, _, _>(|request, _ctx| async move {
|
||||
// let response = request.get("/api/user/current").await;
|
||||
//
|
||||
// with_settings!({
|
||||
// filters => testing::cleanup_user_model()
|
||||
// }, {
|
||||
// assert_debug_snapshot!((response.status_code(),
|
||||
// response.text())); });
|
||||
// })
|
||||
// .await;
|
||||
}
|
||||
1
apps/recorder/tests/tasks/mod.rs
Normal file
1
apps/recorder/tests/tasks/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod seed;
|
||||
42
apps/recorder/tests/tasks/seed.rs
Normal file
42
apps/recorder/tests/tasks/seed.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
//! This task implements data seeding functionality for initializing new
|
||||
//! development/demo environments.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! Run the task with the following command:
|
||||
//! ```sh
|
||||
//! cargo run task
|
||||
//! ```
|
||||
//!
|
||||
//! To override existing data and reset the data structure, use the following
|
||||
//! command with the `refresh:true` argument:
|
||||
//! ```sh
|
||||
//! cargo run task seed_data refresh:true
|
||||
//! ```
|
||||
#![allow(unused_imports)]
|
||||
use loco_rs::{db, prelude::*};
|
||||
use recorder::{app::App, migrations::Migrator};
|
||||
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub struct SeedData;
|
||||
#[async_trait]
|
||||
impl Task for SeedData {
|
||||
fn task(&self) -> TaskInfo {
|
||||
TaskInfo {
|
||||
name: "seed_data".to_string(),
|
||||
detail: "Task for seeding data".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn run(&self, _app_context: &AppContext, _vars: &task::Vars) -> Result<()> {
|
||||
// let refresh = vars.cli.get("refresh").is_some_and(|refresh| refresh ==
|
||||
// "true");
|
||||
//
|
||||
// if refresh {
|
||||
// db::reset::<Migrator>(&app_context.db).await?;
|
||||
// }
|
||||
// let path = std::path::Path::new("src/fixtures");
|
||||
// db::run_app_seed::<App>(&app_context.db, path).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user