Skip to content

Commit

Permalink
port integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcountryman committed Jan 22, 2024
1 parent 0b8adaf commit 46adb27
Show file tree
Hide file tree
Showing 10 changed files with 622 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
89 changes: 89 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Rust

on:
push:
branches:
- main
pull_request: {}

env:
CARGO_TERM_COLOR: always
REDIS_URL: redis://localhost:6379/1
MONGODB_URL: mongodb://localhost:27017
POSTGRES_URL: postgres://postgres:postgres@localhost:5432
MYSQL_URL: mysql://root@127.0.0.1:3306/public

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
rustup toolchain install nightly --profile minimal --component rustfmt --component clippy
- uses: Swatinem/rust-cache@v2
- name: clippy
run: |
cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: rustfmt
run: |
cargo fmt --all --check
check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
- name: cargo doc
env:
RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links"
run: |
cargo doc --all-features --no-deps
test-integration:
needs: check
runs-on: ubuntu-latest

strategy:
matrix:
include:
- store: redis_store
docker: true

- store: mongodb_store
docker: true

- store: postgres_store
features: postgres
docker: true

- store: mysql_store
features: mysql
docker: true

- store: sqlite_store
features: sqlite
docker: false

- store: moka_store
docker: false

- store: caching_store
features: moka-store,sqlite
docker: false

steps:
- uses: actions/checkout@v4
- run: |
rustup toolchain install ${{ env.MSRV }} --profile minimal
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Start session store
if: matrix.docker
run: |
docker compose -f tests/docker-compose.yml up ${{ matrix.store }} -d
- name: Run integration tests
run: |
cargo nextest run ${{ matrix.store }}_test --test integration-tests --features ${{ matrix.features }}
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
members = ["tests"]
resolver = "2"
3 changes: 2 additions & 1 deletion moka-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ impl MokaStore {
/// # Examples
///
/// ```rust
/// use tower_sessions::{MemoryStore, MokaStore};
/// use tower_sessions::MemoryStore;
/// use tower_sessions_moka_store::MokaStore;
/// let session_store = MokaStore::new(Some(2_000));
/// ```
pub fn new(max_capacity: Option<u64>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion mongodb-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl MongoDBStore {
/// # Examples
///
/// ```rust,no_run
/// use tower_sessions::{mongodb::Client, MongoDBStore};
/// use tower_sessions_mongodb_store::{mongodb::Client, MongoDBStore};
///
/// # tokio_test::block_on(async {
/// let database_url = std::option_env!("DATABASE_URL").unwrap();
Expand Down
3 changes: 1 addition & 2 deletions redis-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ impl<C: KeysInterface + Send + Sync> RedisStore<C> {
/// # Examples
///
/// ```rust,no_run
/// use fred::prelude::*;
/// use tower_sessions::RedisStore;
/// use tower_sessions_redis_store::{fred::prelude::*, RedisStore};
///
/// # tokio_test::block_on(async {
/// let pool = RedisPool::new(RedisConfig::default(), None, None, None, 6).unwrap();
Expand Down
28 changes: 28 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "tests"
version = "0.1.0"
edition = "2021"
publish = false

[dev-dependencies]
axum = "0.7"
http = "1.0"
http-body-util = "0.1"
hyper = "1.0"
time = "0.3.30"
tokio = { version = "1", features = ["full"] }
tower = "0.4.13"
tower-cookies = "0.10.0"
tower-sessions = "0.9"
tower-sessions-sqlx-store = { path = "../sqlx-store/", features = [
"sqlite",
"mysql",
"postgres",
] }
tower-sessions-redis-store = { path = "../redis-store/" }
tower-sessions-mongodb-store = { path = "../mongodb-store/" }
tower-sessions-moka-store = { path = "../moka-store/" }

[[test]]
name = "test_integration"
path = "test-integration.rs"
Loading

0 comments on commit 46adb27

Please sign in to comment.