[#2] Adjusted the database to use SQLX for async.

It was determined that Async database access would be prefereable incase
we decide to use a network database instead of sqlite.

Tests and examples need to be checked, but they were made to build.
This commit is contained in:
2025-08-29 18:11:17 -04:00
parent c9c03f9059
commit 0a16667b76
8 changed files with 1946 additions and 320 deletions

View File

@ -1,6 +1,7 @@
use chrono::{NaiveDate, NaiveDateTime};
#![cfg(feature = "publisher")]
use tavern::{Adventurer, Tale, Tavern};
use chrono::NaiveDate;
use tavern::{Adventurer, FrontMatter, Tale, Tavern};
@ -15,17 +16,29 @@ fn generate_tavern() -> Tavern
String::from("https://cybermages.tech/about/myrddin/pic"),
blurb: String::from("I love code!") };
let tale: Tale =
Tale { title: String::from("Test post"),
let fm: FrontMatter = FrontMatter {
title: String::from("Test post"),
slug: String::from("test_post"),
author: author.handle.clone(),
summary: String::from("The Moon is made of cheese!"),
tags: vec![String::from("Space"), String::from("Cheese")],
publish_date: NaiveDate::from_ymd_opt(2025, 12, 25).unwrap().and_hms_opt(13, 10, 41).unwrap(),
publish_date:
NaiveDate::from_ymd_opt(2025, 12, 25).unwrap()
.and_hms_opt(13, 10, 41)
.unwrap()
};
let tale: Tale = Tale {
front_matter: fm,
content: std::path::PathBuf::from("posts/test_post.md") };
Tavern { title: String::from("Runes & Ramblings"),
description: String::from("Join software engineer Jason Smith on his Rust programming journey. Explore program design, tech stacks, and more on this blog from CybeMages, LLC."),
description: String::from("Join software engineer Jason Smith \
on his Rust programming journey. \
Explore program design, tech \
stacks, and more on this blog from \
CybeMages, LLC."),
tales: vec![tale],
authors: vec![author] }
}
@ -81,9 +94,9 @@ fn from_file()
// Assert some known values to make this a real test
let tale = &tavern.tales[0];
assert_eq!(tale.title, "Test post");
assert_eq!(tale.slug, "test_post");
assert_eq!(tale.author, "myrddin");
assert_eq!(tale.front_matter.title, "Test post");
assert_eq!(tale.front_matter.slug, "test_post");
assert_eq!(tale.front_matter.author, "myrddin");
cleanup_temp_file(&path);
}