Lines
100 %
Functions
Branches
use std::collections::HashMap;
use finance::tag::Tag;
use sqlx::types::Uuid;
use super::form_refusal;
fn tag(name: &str, value: &str) -> Tag {
Tag {
id: Uuid::new_v4(),
tag_name: name.to_string(),
tag_value: value.to_string(),
description: None,
}
fn refusal(tags: &[Tag]) -> Result<(), String> {
form_refusal(tags, &[], &HashMap::new(), &[])
#[test]
fn a_plain_and_a_padded_note_are_two_notes() {
let reason = refusal(&[tag("note", "a"), tag("note\t", "b")]).unwrap_err();
assert!(reason.contains("two notes"), "{reason}");
fn a_padded_note_is_one_note() {
assert_eq!(refusal(&[tag("note\t", "a"), tag("k", "v")]), Ok(()));
fn a_plain_and_a_padded_name_hold_two_values_of_one_name() {
let reason = refusal(&[tag("cat", "a"), tag("cat ", "b"), tag("cat!", "c")]).unwrap_err();
assert!(reason.contains("'cat'"), "{reason}");
fn a_padded_name_beside_other_names_is_one_value() {
assert_eq!(
refusal(&[tag("cat ", "a"), tag("cat!", "b"), tag("dog", "c")]),
Ok(())
);