Add lib.rs, scaffold testing
This commit is contained in:
parent
99d05223d7
commit
d9a6938eb6
11 changed files with 57 additions and 14 deletions
14
.justfile
14
.justfile
|
|
@ -19,6 +19,13 @@ test-watch:
|
|||
|
||||
alias tw := test-watch
|
||||
|
||||
# Run cargo check on changes
|
||||
[group('dev')]
|
||||
check-watch:
|
||||
bacon --job check
|
||||
|
||||
alias cw := check-watch
|
||||
|
||||
# Format check on changes
|
||||
[group('dev')]
|
||||
format-watch:
|
||||
|
|
@ -26,6 +33,13 @@ format-watch:
|
|||
|
||||
alias fw := format-watch
|
||||
|
||||
# Lint on changes
|
||||
[group('dev')]
|
||||
lint-watch:
|
||||
bacon --job clippy-all
|
||||
|
||||
alias lw := lint-watch
|
||||
|
||||
# Check before push
|
||||
[group('dev')]
|
||||
push: check
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ mismatching_type_param_order = "warn"
|
|||
missing_errors_doc = "warn"
|
||||
missing_fields_in_debug = "warn"
|
||||
missing_panics_doc = "warn"
|
||||
must_use_candidate = "warn"
|
||||
mut_mut = "warn"
|
||||
naive_bytecount = "warn"
|
||||
needless_continue = "warn"
|
||||
|
|
@ -202,7 +201,6 @@ shadow_unrelated = "warn"
|
|||
single_char_lifetime_names = "warn"
|
||||
string_add = "warn"
|
||||
string_lit_chars_any = "warn"
|
||||
tests_outside_test_module = "warn"
|
||||
unnecessary_self_imports = "warn"
|
||||
unneeded_field_pattern = "warn"
|
||||
unseparated_literal_suffix = "warn"
|
||||
|
|
|
|||
|
|
@ -124,3 +124,12 @@ pub fn deserialize_graph(in_format: &Format, serial: &str) -> Graph {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn smoke() {
|
||||
let n = true;
|
||||
assert!(n);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ fn make_body(code: Option<u16>, message: Option<&str>) -> String {
|
|||
.0
|
||||
}
|
||||
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn not_found() -> Response<Body> {
|
||||
by_code(
|
||||
Some(404),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ use crate::{
|
|||
};
|
||||
use crate::handlers;
|
||||
|
||||
/// # Panics
|
||||
/// Will panic if file read fails.
|
||||
pub async fn file(file_path: &str, content_type: &str) -> Response<Body> {
|
||||
let content = match std::fs::read(file_path) {
|
||||
Ok(s) => s,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use axum::{body::Body, extract::Path, http::Response};
|
|||
|
||||
use crate::{formats::populate_graph, handlers, types::Node};
|
||||
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn node(Path(id): Path<String>) -> Response<Body> {
|
||||
let mut context = tera::Context::new();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ pub async fn nexus(template: &str) -> Response<Body> {
|
|||
handlers::template::by_filename(template, &context, 500, None, false)
|
||||
}
|
||||
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn search(Form(query): Form<Query>) -> Redirect {
|
||||
Redirect::permanent(format!("/node/{}", query.node).as_str())
|
||||
}
|
||||
|
|
|
|||
10
src/lib.rs
Normal file
10
src/lib.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use std::{sync, time};
|
||||
|
||||
pub mod formats;
|
||||
pub mod types;
|
||||
pub mod handlers;
|
||||
pub mod syntax;
|
||||
pub mod dev;
|
||||
|
||||
pub static ONSET: sync::LazyLock<time::Instant> =
|
||||
sync::LazyLock::new(time::Instant::now);
|
||||
22
src/main.rs
22
src/main.rs
|
|
@ -1,17 +1,8 @@
|
|||
use std::{backtrace, io, panic, sync, time};
|
||||
use std::{backtrace, io, panic};
|
||||
|
||||
use axum::{routing::get, Router};
|
||||
|
||||
use formats::Format;
|
||||
|
||||
mod formats;
|
||||
mod types;
|
||||
mod handlers;
|
||||
mod syntax;
|
||||
mod dev;
|
||||
|
||||
static ONSET: sync::LazyLock<time::Instant> =
|
||||
sync::LazyLock::new(time::Instant::now);
|
||||
use en::{ONSET, handlers, syntax, dev, formats::Format};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
|
|
@ -99,3 +90,12 @@ async fn main() -> io::Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn smoke() {
|
||||
let e = true;
|
||||
assert!(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Arguments {
|
||||
pub hostname: String,
|
||||
pub port: u16,
|
||||
|
|
@ -20,6 +20,7 @@ impl Arguments {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn parse(&self) -> Arguments {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
parse(self, &args)
|
||||
|
|
|
|||
6
tests/smoke.rs
Normal file
6
tests/smoke.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#[test]
|
||||
fn add() {
|
||||
let e = 0_i32;
|
||||
let n = 0_i32;
|
||||
assert_eq!(e, n);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue