Skip to content
Snippets Groups Projects
Unverified Commit b7082b2e authored by Volkor Barbarian Warrior's avatar Volkor Barbarian Warrior
Browse files

db url in config, add more tests

This hopefully fixes the tests in CI
parent 9898a9ef
No related branches found
No related tags found
No related merge requests found
# name: Format, check and test
name: cargo-check
name: format, check and test
on: [push, pull_request]
jobs:
check:
name: cargo check
format:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout@v3
- uses: https://github.com/dtolnay/rust-toolchain@stable
- run: cargo check --all-features
\ No newline at end of file
with:
components: rustfmt
- run: cargo fmt --all-features
clippy:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout@v3
- uses: https://github.com/dtolnay/rust-toolchain@stable
with:
components: clippy
- run: cargo clippy --all-features
test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout@v3
- uses: https://github.com/dtolnay/rust-toolchain@stable
- run: cargo test --all-features
\ No newline at end of file
/target
files.db
/files/
ephemeral.db
ephemeral-testing.db
.timetracker
ephemeral.db-shm
ephemeral.db-wal
......
......@@ -12,9 +12,11 @@ nginx_sendfile = false
## Available SQL backends: sqlite, postgres
sql_backend = "sqlite"
# URL for postgres, see below for more information
# URL for the database, supporting both postgres and sqlite
# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
postgres_url = "postgres://ephemeral:changeme@localhost:5432/ephemeral"
# url = "postgres://ephemeral:changeme@localhost:5432/ephemeral"
url = "sqlite://ephemeral.db"
[logging]
# Controls the logging level of the ephemeral program, and the crates it uses.
......
......@@ -12,9 +12,11 @@ nginx_sendfile = false
## Available SQL backends: sqlite, postgres
sql_backend = "sqlite"
# URL for postgres, see below for more information
# URL for the database, supporting both postgres and sqlite
# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
postgres_url = "postgres://ephemeral:changeme@localhost:5432/ephemeral"
# url = "postgres://ephemeral:changeme@localhost:5432/ephemeral"
url = "sqlite://ephemeral-testing.db"
[logging]
# Controls the logging level of the ephemeral program, and the crates it uses.
......
File added
......@@ -54,12 +54,16 @@ async fn main() {
let sql = CONFIG
.get_string("database.sql_backend")
.expect("Couldn't find 'sql_backend' in config. :(");
// Pipe SQL url to database initialization
let sqlurl = CONFIG
.get_string("database.url")
.expect("Couldn't find 'url' in config. :(");
// This /might be able to be a match statement, but I couldn't figure it out and want to go to bed.
// REVIEW: yeah do a match. Also I'm pretty sure there is an enum somewhere you can match instead of strings
if sql == "sqlite" {
tracing::info!("Using SQLite backend");
let pool = SqlitePool::connect("sqlite:ephemeral.db").await.unwrap();
let pool = SqlitePool::connect(&sqlurl).await.unwrap();
SQLITE.set(pool).unwrap();
} else if sql == "postgres" {
tracing::info!("Using Postgres backend");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment