From 3779092d08e3cf6ae039445e9cf898589bac3f57 Mon Sep 17 00:00:00 2001 From: Jacob Phillips Date: Wed, 16 Aug 2023 22:03:10 -0400 Subject: [PATCH] update examples, test, clippy --- example/src/person.rs | 14 ++++++++------ example/src/worked_at.rs | 2 +- example/tests/basic_crud.rs | 2 +- macros/src/derive.rs | 3 --- macros/src/derive/entity/field/field_type.rs | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/example/src/person.rs b/example/src/person.rs index 20a0536..04ef052 100644 --- a/example/src/person.rs +++ b/example/src/person.rs @@ -1,7 +1,9 @@ -use cypher_dto::{node, relation, stamps}; +use cypher_dto::{timestamps, Node, Relation}; /// Single ID field and optional timestamps. Has example of `new()` and `into_builder()` methods. -#[node(stamps, name = "Person2")] +#[timestamps] +#[derive(Node, Clone)] +#[name = "Person2"] pub struct Person { id: String, #[name = "name2"] @@ -11,12 +13,12 @@ pub struct Person { colors: Vec, } -#[relation] +#[derive(Relation)] struct Knows; #[cfg(test)] mod tests { - use cypher_dto::{NodeEntity, RelationBound}; + use cypher_dto::{Entity, NodeEntity, RelationBound, RelationEntity}; use super::*; @@ -34,17 +36,17 @@ mod tests { &["red".to_owned(), "blue".to_owned()], ); assert_eq!(p.id(), "id"); - let p = p.into_builder().name("name2").build().unwrap(); + let p = p.into_builder().name("name2").build(); assert_eq!(p.name(), "name2"); assert_eq!(p.colors(), &["red", "blue"]); assert_eq!(p.age(), Some(42)); let now = chrono::Utc::now(); + assert_eq!( p.clone() .into_builder() .created_at(Some(now)) .build() - .unwrap() .created_at(), Some(&now), ); diff --git a/example/src/worked_at.rs b/example/src/worked_at.rs index ad542d2..1b81eb6 100644 --- a/example/src/worked_at.rs +++ b/example/src/worked_at.rs @@ -14,7 +14,7 @@ pub struct WorkedAt { #[cfg(test)] mod tests { use super::*; - use cypher_dto::{QueryFields, StampMode}; + use cypher_dto::{Entity, StampMode}; #[test] fn rename() { diff --git a/example/tests/basic_crud.rs b/example/tests/basic_crud.rs index 20da4c5..8c41344 100644 --- a/example/tests/basic_crud.rs +++ b/example/tests/basic_crud.rs @@ -46,7 +46,7 @@ async fn basic_crud() { assert_eq!(alice.identifier(), alice_id); // Update Alice's name - let alice = alice.into_builder().name("Allison").build().unwrap(); + let alice = alice.into_builder().name("Allison").build(); graph.run(alice.update()).await.unwrap(); let mut stream = graph.execute(alice_id.read()).await.unwrap(); diff --git a/macros/src/derive.rs b/macros/src/derive.rs index 578e5aa..7376609 100644 --- a/macros/src/derive.rs +++ b/macros/src/derive.rs @@ -69,8 +69,5 @@ mod tests { assert_eq!(parse_name_meta(&attr.meta), Some("Foo".to_owned())); let attr: Attribute = parse_quote!(#[name = "Foo"]); assert_eq!(parse_name_meta(&attr.meta), Some("Foo".to_owned())); - let args = quote!(#[foo(name = "Foo", stamps = "full")]); - let meta: Meta = syn::parse2(args).unwrap(); - assert_eq!(parse_name_meta(&meta), Some("Foo".to_owned())); } } diff --git a/macros/src/derive/entity/field/field_type.rs b/macros/src/derive/entity/field/field_type.rs index 022940d..0691032 100644 --- a/macros/src/derive/entity/field/field_type.rs +++ b/macros/src/derive/entity/field/field_type.rs @@ -119,7 +119,7 @@ impl ArgHelper { field_into_getter_suffix, } } else { - let is_copy = is_copy_type(&ty); + let is_copy = is_copy_type(ty); Self { arg_type: ty.clone(), arg_into_field_suffix: quote!(),