Skip to content
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

Fix tests and add workflow to run tests and format code #60

Merged
merged 3 commits into from
Oct 11, 2024
Merged
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
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests and Formatting

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
everything:
name: Rust/JS Checks/Formatting
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Run cargo fmt
id: fmt
run: cargo fmt --all -- --check
continue-on-error: true
- name: Run cargo clippy
id: clippy
continue-on-error: true
run: cargo clippy --all -- -D warnings
- name: Run cargo test
id: test
continue-on-error: true
run: cargo test
- name: Check if code is properly formatted
if: steps.fmt.outcome != 'success'
run: exit 1
- name: Check if clippy is happy
if: steps.clippy.outcome != 'success'
run: exit 1
- name: Check if test succeeded
if: steps.test.outcome != 'success'
run: exit 1
63 changes: 63 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion examples/003-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn create_account(
return Err(username.error("username 'admin' is not allowed").into());
}

let _res = conn.transaction::<_, ft_sdk::Error, _>(|c| {
conn.transaction::<_, ft_sdk::Error, _>(|c| {
// do a select query to see if username is already taken
if diesel::select(diesel::dsl::exists(
account_user::table.filter(account_user::username.eq(&username.0)),
Expand Down
1 change: 1 addition & 0 deletions ft-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ uuid.workspace = true

[dev-dependencies]
pretty_assertions = "1"
cookie.workspace = true
8 changes: 4 additions & 4 deletions ft-sdk/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ pub fn binary<S: AsRef<str>>(content: bytes::Bytes, content_type: S) -> Result {
/// a 200-OK response, with an HTML meta-refresh tag to redirect the browser.
///
/// ```rust
/// let cookie = cookie::Cookie::build((ft_sdk::auth::SESSION_KEY, sid))
/// .domain(host.without_port())
/// .path("/")
/// let cookie = cookie::Cookie::build((ft_sdk::auth::SESSION_KEY, "some-uniq-key"))
/// .domain("127.0.0.1")
/// .path("")
/// .max_age(cookie::time::Duration::seconds(34560000))
/// .same_site(cookie::SameSite::Strict)
/// .build();
/// ft_sdk::data::browser_redirect_with_cookie("/", cookie)
/// ft_sdk::data::browser_redirect_with_cookie("/", http::HeaderValue::from_str(cookie.to_string().as_str()).unwrap());
/// ```
pub fn browser_redirect_with_cookie<S: AsRef<str>>(url: S, c: http::HeaderValue) -> Result {
Ok(ft_sdk::chr::CHR::new(Output::Redirect(
Expand Down
2 changes: 1 addition & 1 deletion ft-sys/src/diesel_sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ mod types;

pub use backend::Sqlite;
pub use connection::SqliteConnection;
pub use sqlite_value::{Cursor, SqliteValue};
pub(crate) use no_instrumentation::NoInstrumentation;
pub use sqlite_value::{Cursor, SqliteValue};
Loading