Skip to content

Commit

Permalink
テストに必要なものの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
PonponJuice committed Oct 30, 2024
1 parent 11b435d commit bc3f2aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export DB_HOSTNAME="localhost"
export DB_PORT="3306"
export DB_DATABASE="world"
export RUST_LOG="debug"
export DATABASE_URL="mariadb://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT/$DB_DATABASE"

export MAIL_ADDRESS="[email protected]"
export MAIL_PASSWORD="**** **** **** ****"
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ env:
jobs:
test:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: world
TZ: Asia/Tokyo
ports:
- 3306:3306
options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -32,7 +42,7 @@ jobs:
- name: Build test
run: cargo build --release --verbose
- name: Run test
run: cargo test --verbose
run: source .env.dev && cargo test --verbose
- name: Lint with clippy
run: cargo clippy --all-targets --all-features
- name: Check formatting
Expand Down
11 changes: 11 additions & 0 deletions src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ impl Repository {

Ok(())
}

pub async fn create_by_pool(pool: sqlx::MySqlPool) -> anyhow::Result<Self> {
let session_store =
MySqlSessionStore::from_client(pool.clone()).with_table_name("user_sessions");

Ok(Self {
pool,
session_store,
bcrypt_cost: bcrypt::DEFAULT_COST,
})
}
}

fn get_option_from_env() -> anyhow::Result<MySqlConnectOptions> {
Expand Down

0 comments on commit bc3f2aa

Please sign in to comment.