mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
* fix: fixture macro attribute * remove extra new line * add extra new line * feat: add test for slqx::test macro * feat: update test for sqlx::test macro * remove old macro test * feat: add postgres and sqlite test * rust format * cargo fmt * fix fixtures execution order in test
This commit is contained in:
parent
ebf04ff499
commit
1d8eb2add4
3 changed files with 23 additions and 3 deletions
|
@ -187,7 +187,10 @@ fn expand_advanced(args: AttributeArgs, input: syn::ItemFn) -> crate::Result<Tok
|
|||
|
||||
#[cfg(feature = "migrate")]
|
||||
fn parse_args(attr_args: AttributeArgs) -> syn::Result<Args> {
|
||||
use syn::{punctuated::Punctuated, Expr, Lit, LitStr, Meta, MetaNameValue, Token};
|
||||
use syn::{
|
||||
parenthesized, parse::Parse, punctuated::Punctuated, token::Comma, Expr, Lit, LitStr, Meta,
|
||||
MetaNameValue, Token,
|
||||
};
|
||||
|
||||
let mut fixtures = Vec::new();
|
||||
let mut migrations = MigrationsOpt::InferredPath;
|
||||
|
@ -208,8 +211,9 @@ fn parse_args(attr_args: AttributeArgs) -> syn::Result<Args> {
|
|||
parse_fixtures_path_args(&mut fixtures_type, val)?;
|
||||
} else if meta.path.is_ident("scripts") {
|
||||
// fixtures(path = "<path>", scripts("<file_1>","<file_2>")) checking `scripts` argument
|
||||
let parser = <Punctuated<LitStr, Token![,]>>::parse_terminated;
|
||||
let list = parser.parse2(list.tokens.clone())?;
|
||||
let content;
|
||||
parenthesized!(content in meta.input);
|
||||
let list = content.parse_terminated(<LitStr as Parse>::parse, Comma)?;
|
||||
parse_fixtures_scripts_args(&mut fixtures_type, list, &mut fixtures_local)?;
|
||||
} else {
|
||||
return Err(syn::Error::new_spanned(
|
||||
|
|
|
@ -178,3 +178,11 @@ async fn it_gets_comments(pool: PgPool) -> sqlx::Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx::test(
|
||||
migrations = "tests/postgres/migrations",
|
||||
fixtures(path = "../fixtures/postgres", scripts("users", "posts"))
|
||||
)]
|
||||
async fn this_should_compile(_pool: PgPool) -> sqlx::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -97,3 +97,11 @@ async fn it_gets_comments(pool: SqlitePool) -> sqlx::Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx::test(
|
||||
migrations = "tests/sqlite/migrations",
|
||||
fixtures(path = "./fixtures", scripts("users", "posts"))
|
||||
)]
|
||||
async fn this_should_compile(_pool: SqlitePool) -> sqlx::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue