Skip to content
Open

test #47

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ft-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sqlite-default = ["sqlite"]
sqlite = ["ft-sys/sqlite", "diesel"]
auth-provider = []
field-extractors = []
test = ["diesel/sqlite", "diesel/postgres"]

[dependencies]
anyhow.workspace = true
Expand Down
15 changes: 15 additions & 0 deletions ft-sdk/src/auth/schema.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(feature = "test"))]
diesel::table! {
use diesel::sql_types::*;

Expand All @@ -11,6 +12,20 @@ diesel::table! {
}
}

#[cfg(feature = "test")]
diesel::table! {
use diesel::sql_types::*;

fastn_user (id) {
id -> Int8,
name -> Nullable<Text>,
identity -> Nullable<Text>,
data -> Text,
created_at -> Int8,
updated_at -> Int8,
}
}

diesel::table! {
use diesel::sql_types::*;

Expand Down
13 changes: 11 additions & 2 deletions ft-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,21 @@ pub type FormError = std::collections::HashMap<String, String>;
#[cfg(all(feature = "sqlite-default", feature = "postgres-default"))]
compile_error!("Both sqlite and postgres features are enabled. Only one should be enabled.");

#[cfg(feature = "sqlite-default")]
#[cfg(any(feature = "sqlite-default", not(feature = "test")))]
pub type Connection = SqliteConnection;

#[cfg(feature = "postgres-default")]
#[cfg(any(feature = "postgres-default", not(feature = "test")))]
pub type Connection = PgConnection;

#[cfg(feature = "test")]
pub type Connection = diesel::sqlite::SqliteConnection;

#[cfg(feature = "test")]
pub fn default_connection() -> Result<Connection, ConnectionError> {
use diesel::prelude::*;
Ok(diesel::sqlite::SqliteConnection::establish(":memory:").unwrap())
}

#[cfg(any(feature = "sqlite-default", feature = "postgres-default"))]
pub fn default_connection() -> Result<Connection, ConnectionError> {
#[cfg(feature = "sqlite-default")]
Expand Down