more tests
This commit is contained in:
parent
92c9daeb82
commit
a9f2eacd56
|
@ -19,11 +19,11 @@ pretty_env_logger = "0"
|
|||
rand = "0"
|
||||
ructe = "0.11"
|
||||
serde_dhall = "0.5.3"
|
||||
serde_yaml = "0.8"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_yaml = "0.8"
|
||||
thiserror = "1"
|
||||
tokio = { version = "0.2", features = ["macros"] }
|
||||
warp = "0.2"
|
||||
thiserror = "1"
|
||||
|
||||
[build-dependencies]
|
||||
ructe = { version = "0.11", features = ["warp02"] }
|
||||
|
|
36
src/app.rs
36
src/app.rs
|
@ -1,4 +1,4 @@
|
|||
use crate::signalboost::Person;
|
||||
use crate::{post::Post, signalboost::Person};
|
||||
use anyhow::Result;
|
||||
use comrak::{markdown_to_html, ComrakOptions};
|
||||
use serde::Deserialize;
|
||||
|
@ -33,6 +33,10 @@ pub struct State {
|
|||
pub cfg: Config,
|
||||
pub signalboost: Vec<Person>,
|
||||
pub resume: String,
|
||||
pub blog: Vec<Post>,
|
||||
pub gallery: Vec<Post>,
|
||||
pub talks: Vec<Post>,
|
||||
pub everything: Vec<Post>,
|
||||
}
|
||||
|
||||
pub fn init(cfg: PathBuf) -> Result<State> {
|
||||
|
@ -40,10 +44,40 @@ pub fn init(cfg: PathBuf) -> Result<State> {
|
|||
let sb = cfg.signalboost.clone();
|
||||
let resume = fs::read_to_string(cfg.resume_fname.clone())?;
|
||||
let resume: String = markdown(&resume);
|
||||
let blog = crate::post::load("blog")?;
|
||||
let gallery = crate::post::load("gallery")?;
|
||||
let talks = crate::post::load("talks")?;
|
||||
let mut everything: Vec<Post> = vec![];
|
||||
|
||||
{
|
||||
let blog = blog.clone();
|
||||
let gallery = gallery.clone();
|
||||
let talks = talks.clone();
|
||||
everything.extend(blog.iter().cloned());
|
||||
everything.extend(gallery.iter().cloned());
|
||||
everything.extend(talks.iter().cloned());
|
||||
};
|
||||
|
||||
everything.sort();
|
||||
everything.reverse();
|
||||
|
||||
Ok(State {
|
||||
cfg: cfg,
|
||||
signalboost: sb,
|
||||
resume: resume,
|
||||
blog: blog,
|
||||
gallery: gallery,
|
||||
talks: talks,
|
||||
everything: everything,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
#[test]
|
||||
fn init() -> Result<()> {
|
||||
super::init("./config.dhall".into())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{cmp::Ordering, fs};
|
|||
|
||||
pub mod frontmatter;
|
||||
|
||||
#[derive(Eq, PartialEq, Debug)]
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct Post {
|
||||
pub front_matter: frontmatter::Data,
|
||||
pub link: String,
|
||||
|
@ -60,7 +60,19 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn blog() -> Result<()> {
|
||||
load("./blog")?;
|
||||
load("blog")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gallery() -> Result<()> {
|
||||
load("gallery")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn talks() -> Result<()> {
|
||||
load("talks")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,3 +10,14 @@ pub struct Person {
|
|||
|
||||
pub twitter: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
#[test]
|
||||
fn load() -> Result<()> {
|
||||
let people: Vec<super::Person> = serde_dhall::from_file("./signalboost.dhall").parse()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue