Housekeeping. Unit tests, coverage, formatter, linter. #4

Merged
drew merged 1 commit from housekeep into main 2025-09-20 19:30:36 +00:00
4 changed files with 8 additions and 7 deletions

View file

@ -32,7 +32,7 @@ impl TaskModel {
title: &str,
description: Option<&str>,
) -> Result<TaskModel> {
if title.len() == 0 {
if title.is_empty() {
bail!("Title must not be empty");
}
@ -70,10 +70,10 @@ impl TaskModel {
)
.bind(&self.title)
.bind(&self.description)
.bind(&self.status)
.bind(self.status)
.bind(now)
.bind(&self.completed_at)
.bind(&self.id)
.bind(self.completed_at)
.bind(self.id)
.execute(pool)
.await?;

View file

@ -9,6 +9,7 @@ use axum::{
// AppError
// Borrowed from example: https://github.com/tokio-rs/axum/blob/axum-v0.8.4/examples/anyhow-error-response/src/main.rs
#[derive(Debug)]
pub enum AppError {
InternalError(anyhow::Error),
JsonExtractError(JsonRejection),
@ -74,7 +75,7 @@ impl From<PathRejection> for AppError {
impl From<anyhow::Error> for AppError {
fn from(err: anyhow::Error) -> Self {
Self::InternalError(err.into())
Self::InternalError(err)
}
}

View file

@ -73,7 +73,7 @@ pub async fn update_task(
let mut model = TaskModel::get_by_id(&pool, task_id).await?;
if let Some(title) = input.title {
if title.len() == 0 {
if title.is_empty() {
return Err(AppError::Unprocessable(
"Title must not be empty".to_string(),
));