Skip to content

Commit

Permalink
Add test harness for CockroachDB, convert examples to tests (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein authored Nov 13, 2023
1 parent 46c2c40 commit 2d15684
Show file tree
Hide file tree
Showing 13 changed files with 1,647 additions and 125 deletions.
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For use with direnv: https://direnv.net
# See also: ./env.sh

PATH_add out/cockroachdb/bin
4 changes: 4 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
steps:
# actions/checkout@v2
- uses: actions/checkout@72f2cec99f417b1a1c5e2e88945068983b7965f9
- name: Download CockroachDB
run: ./tools/ci_download_cockroachdb
- name: Add CockroachDB to PATH
run: echo ./out/cockroachdb/bin >> $GITHUB_PATH
- name: Build
run: cargo build --tests --verbose
- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
Cargo.lock
out
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ thiserror = "1.0"
tokio = { version = "1.32", default-features = false, features = [ "rt-multi-thread" ] }

[dev-dependencies]
anyhow = "1.0"
diesel = { version = "2.1.0", features = [ "postgres", "r2d2" ] }
tokio = { version = "1.32", features = [ "macros"] }
libc = "0.2.150"
tempfile = "3.8"
tokio = { version = "1.32", features = [ "macros", "fs", "process" ] }
tokio-postgres = { version = "0.7", features = [ "with-chrono-0_4", "with-uuid-1" ] }
122 changes: 0 additions & 122 deletions examples/usage.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/async_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ where
.await
{
Ok(()) => Err(user_error),
Err(err) => Err(err.into()),
Err(err) => Err(err),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<T> OptionalExtension<T> for Result<T, ConnectionError> {

self_as_query_result
.optional()
.map_err(|e| ConnectionError::Query(e))
.map_err(ConnectionError::Query)
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Tests

This directory includes some integration tests, specifically with the
CockroachDB database, which uses a PostgreSQL protocol.

Tests expect that the CockroachDB binary exist, and fail without it.

To download a local copy of CockroachDB:

```bash
./tools/ci_download_cockroachdb
```

This downloads a binary to `./out/cockroachdb/bin/cockoach`. If you'd like
to use your own binary here, replace this binary with your own executable.
Loading

0 comments on commit 2d15684

Please sign in to comment.