-
-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore: test cases for sea-orm-macros #504
Comments
Hey I'd love to try this out, i am new to the project but would love the learning. |
Hey @sbshah97, happy new year! Sorry for the delay. Do you have anything implementation plan in mind that you want to share? We better have a clear and workable testing plan before coding. |
I don't think I have any clear plan. I'd love to play with the code and get it up first. I plan to run through the code using the CONTRIBUTING guide and set the repo up on my local system. Do you have any additional pointers apart from the Getting Started guide? Also any pointers on how I can call this particular code path ? |
Is this ticket about asserting that the generated code by a macro matches the expected value? |
This ticket want to test the expected behaviour of An example mock test: sea-orm/src/executor/update.rs Lines 160 to 278 in d80e61e
|
Sorry I have a rather trivial question here. Is this the method we are looking to test on? /// Method to derive a [QueryResult](sea_orm::QueryResult)
pub fn expand_derive_from_query_result(ident: Ident, data: Data) -> syn::Result<TokenStream> {
let fields = match data {
Data::Struct(DataStruct {
fields: Fields::Named(named),
..
}) => named.named,
_ => {
return Ok(quote_spanned! {
ident.span() => compile_error!("you can only derive FromQueryResult on structs");
})
}
};
let field: Vec<Ident> = fields
.into_iter()
.map(|Field { ident, .. }| format_ident!("{}", ident.unwrap().to_string()))
.collect();
let name: Vec<TokenStream> = field
.iter()
.map(|f| {
let s = f.unraw().to_string();
quote! { #s }
})
.collect();
Ok(quote!(
#[automatically_derived]
impl sea_orm::FromQueryResult for #ident {
fn from_query_result(row: &sea_orm::QueryResult, pre: &str) -> std::result::Result<Self, sea_orm::DbErr> {
Ok(Self {
#(#field: row.try_get(pre, #name)?),*
})
}
}
))
} |
thanks for the catch! @billy1624 I imagine we can also add some test cases using the MockInterface?
Originally posted by @tyt2y3 in #494 (comment)
The text was updated successfully, but these errors were encountered: