diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index d538dd4..7d0d4d1 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -59,4 +59,6 @@ jobs: override: true - name: test - run: TEST_DB_URL=postgresql://test_user:test_password@localhost:5432/test_db cargo test + env: + TEST_DB_URL: postgresql://test_user:test_password@localhost:5432/test_db + run: cargo test diff --git a/README.md b/README.md index 4fe3636..67b0054 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ for more on how to use this project. The repository is comprised of three crates: - `taskchampion-sync-server-core` implements the core of the protocol - - `taskchmpaion-sync-server-storage-sqlite` implements an SQLite backend for the core - - `taskchmpaion-sync-server-storage-posrgres` implements a Postgres backend for the core + - `taskchampion-sync-server-storage-sqlite` implements an SQLite backend for the core + - `taskchampion-sync-server-storage-postgres` implements a Postgres backend for the core - `taskchampion-sync-server` implements a simple HTTP server for the protocol ### Building From Source diff --git a/postgres/src/lib.rs b/postgres/src/lib.rs index 02363b5..690df22 100644 --- a/postgres/src/lib.rs +++ b/postgres/src/lib.rs @@ -153,7 +153,7 @@ impl StorageTxn for Txn { async fn new_client(&mut self, latest_version_id: Uuid) -> anyhow::Result<()> { self.db_client() .execute( - "INSERT into clients (client_id, latest_version_id) values ($1, $2)", + "INSERT INTO clients (client_id, latest_version_id) VALUES ($1, $2)", &[&self.client_id, &latest_version_id], ) .await @@ -166,11 +166,11 @@ impl StorageTxn for Txn { self.db_client() .execute( "UPDATE clients - set snapshot_version_id = $1, + SET snapshot_version_id = $1, versions_since_snapshot = $2, snapshot_timestamp = $3, snapshot = $4 - where client_id = $5", + WHERE client_id = $5", &[ &snapshot.version_id, &(snapshot.versions_since as i32), @@ -553,19 +553,6 @@ mod test { .await } - #[tokio::test] - async fn test_get_version_none() -> anyhow::Result<()> { - with_db(async |connection_string, db_client| { - let storage = PostgresStorage::new(connection_string).await?; - let client_id = make_client(&db_client).await?; - let mut txn = storage.txn(client_id).await?; - assert_eq!(txn.get_version_by_parent(Uuid::new_v4()).await?, None); - assert_eq!(txn.get_version(Uuid::new_v4()).await?, None); - Ok(()) - }) - .await - } - #[tokio::test] async fn test_get_version() -> anyhow::Result<()> { with_db(async |connection_string, db_client| { @@ -603,7 +590,7 @@ mod test { } #[tokio::test] - async fn add_version() -> anyhow::Result<()> { + async fn test_add_version() -> anyhow::Result<()> { with_db(async |connection_string, db_client| { let storage = PostgresStorage::new(connection_string).await?; let client_id = make_client(&db_client).await?; @@ -628,7 +615,7 @@ mod test { /// When an add_version call specifies an incorrect `parent_version_id, it fails. This is /// typically avoided by calling `get_client` beforehand, which (due to repeatable reads) /// allows the caller to check the `latest_version_id` before calling `add_version`. - async fn add_version_mismatch() -> anyhow::Result<()> { + async fn test_add_version_mismatch() -> anyhow::Result<()> { with_db(async |connection_string, db_client| { let storage = PostgresStorage::new(connection_string).await?; let client_id = make_client(&db_client).await?; @@ -649,7 +636,7 @@ mod test { #[tokio::test] /// Adding versions to two different clients can proceed concurrently. - async fn add_version_no_conflict_different_clients() -> anyhow::Result<()> { + async fn test_add_version_no_conflict_different_clients() -> anyhow::Result<()> { with_db(async |connection_string, db_client| { let storage = PostgresStorage::new(connection_string).await?;