♻️🧪 vanth: Add From impl, make struct public, refactor tests

- Implemented `From<Value>` for `HashedValue`
- Made `ReferenceRetrievalTask` struct public
- Removed extraneous space in `#[derive]` attribute for `ReferenceValue`
- Consolidated integration tests into `tests/integration` directory
- Added new `test_derive` function with debug output
- Deleted obsolete test files: `main.rs`, `store.rs`, and `test_node.rs`
This commit is contained in:
Markus Scully 2025-08-05 11:40:56 +03:00
parent 8b76fcb659
commit 94105daca1
Signed by: mascully
GPG key ID: 93CA5814B698101C
7 changed files with 47 additions and 33 deletions

View file

@ -60,6 +60,15 @@ pub struct HashedValue {
inner: Value
}
impl From<Value> for HashedValue {
fn from(value: Value) -> Self {
Self {
content_hash: hash(&value),
inner: value,
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Value {
ty: Ty,
@ -127,7 +136,7 @@ impl <T: Clone + Serialize> Reference<T> {
}
#[derive(Component, Clone, Debug, Deserialize, Serialize)]
struct ReferenceRetrievalTask {
pub struct ReferenceRetrievalTask {
}

View file

@ -7,3 +7,8 @@ use vanth::Vanth;
struct Foo {
}
#[test]
fn test_derive() {
println!("yeet");
}

View file

@ -1,6 +1,9 @@
use serde::{Deserialize, Serialize};
use vanth::{Component, Node, Reference};
mod derive;
mod fs;
// #[test]
// fn test_store() {
// #[derive(Clone, Deserialize, Serialize)]
@ -26,3 +29,31 @@ use vanth::{Component, Node, Reference};
// node.save("entity_1", entity_components);
// }
// #[test]
// fn test_store() {
// #[derive(Deserialize, Serialize)]
// struct Foo {
// a: u32,
// b: f32,
// }
// impl Component for Foo {
// fn id() -> String {
// "foo".into()
// }
// }
// let node = Node::in_memory();
// let entity_id = "entity_1";
// let entity_components = (Foo { a: 5, b: 6.0 },);
// node.save("entity_1", entity_components);
// }
// #[test]
// fn test_entity_count_zero() {
// let mut node = Node::new();
// assert_eq!(node.entity_count(), 0);
// }

View file

@ -1,24 +0,0 @@
use serde::{Deserialize, Serialize};
use vanth::{Component, Node};
// #[test]
// fn test_store() {
// #[derive(Deserialize, Serialize)]
// struct Foo {
// a: u32,
// b: f32,
// }
// impl Component for Foo {
// fn id() -> String {
// "foo".into()
// }
// }
// let node = Node::in_memory();
// let entity_id = "entity_1";
// let entity_components = (Foo { a: 5, b: 6.0 },);
// node.save("entity_1", entity_components);
// }

View file

@ -1,7 +0,0 @@
use vanth::Node;
#[test]
fn test_entity_count_zero() {
let mut node = Node::new();
assert_eq!(node.entity_count(), 0);
}