pub struct TestPgBuilder<S>{ /* private fields */ }Expand description
Builder for creating a TestPg instance with custom configuration.
Implementations§
Source§impl<S> TestPgBuilder<S>
impl<S> TestPgBuilder<S>
Sourcepub fn new(database_url: String, migrations: S) -> Self
pub fn new(database_url: String, migrations: S) -> Self
Create a new TestPgBuilder with the given database URL and migrations.
Sourcepub fn with_extensions(self, extensions: Vec<String>) -> Self
pub fn with_extensions(self, extensions: Vec<String>) -> Self
Add a list of PostgreSQL extensions to be installed before running migrations.
§Example
use sqlx_db_tester::TestPgBuilder;
use std::path::Path;
let tdb = TestPgBuilder::new(
"postgres://postgres:postgres@localhost:5432".to_string(),
Path::new("./fixtures/migrations")
)
.with_extensions(vec!["uuid-ossp".to_string(), "postgis".to_string()])
.build();Sourcepub fn with_seeds<P: AsRef<Path>>(self, seeds_path: P) -> Self
pub fn with_seeds<P: AsRef<Path>>(self, seeds_path: P) -> Self
Add a path to a directory containing seed SQL files.
Seed files should be named with the pattern <timestamp>_<description>.sql
(e.g., 20240101120000_initial_data.sql). They will be executed in
timestamp order after migrations are complete.
§Example
use sqlx_db_tester::TestPgBuilder;
use std::path::Path;
let tdb = TestPgBuilder::new(
"postgres://postgres:postgres@localhost:5432".to_string(),
Path::new("./fixtures/migrations")
)
.with_seeds(Path::new("./fixtures/seeds"))
.build();Auto Trait Implementations§
impl<S> Freeze for TestPgBuilder<S>where
S: Freeze,
impl<S> RefUnwindSafe for TestPgBuilder<S>where
S: RefUnwindSafe,
impl<S> Send for TestPgBuilder<S>
impl<S> Sync for TestPgBuilder<S>
impl<S> Unpin for TestPgBuilder<S>where
S: Unpin,
impl<S> UnwindSafe for TestPgBuilder<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more