almost a unittest

This commit is contained in:
bel
2023-11-26 22:19:13 -07:00
parent f81465534e
commit d565e9d382
4 changed files with 155 additions and 0 deletions

View File

@@ -1,3 +1,36 @@
use serde::{Serialize, Deserialize};
fn main() {
println!("Hello, world!");
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Storage {
adds: []Add,
}
struct Add {
t: i64,
add: String,
tag: String,
}
fn load_storage(path: String) -> Result<Storage, String> {
Err("failed".to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_testdata_standalone_yaml() {
assert_eq!(
load_storage("./testdata/standalone.yaml".to_string()).expect("cant load standalone.yaml"),
Storage{adds: {
Add{t: 1, add: "def".to_string(), tag: "abc".to_string()},
Add{t: 2, add: "ghi".to_string(), tag: "".to_string()},
}},
);
}
}