Skip to content

Commit e039048

Browse files
authored
Support encrypted connections (#88)
* Fix example doc which passes a &&str * Remove rust-toolchain file While our MSRV is 1.60.0, rust-analyzer runs into a bunch of problems with this version where it can no longer expand proc macros. For development, one should use their latest stable version that works with whatever rust-analyzer or any other dev setup they have and not have to be forced to use 1.60. The downside is that it is easier to accidentally introduce code that would require a later Rust version, but we should catch that with our MSRV CI tests. * Support encrypted connections as well * Allow tests against external servers * Update readme about testing * Set minimum thiserror to 1.0.2 It's the version that contains `#[from]`. * Always use the 2021 resolver in the workspace * Add segment about CI lockfiles to the readme * Update CI lock files * Remove pub from internal constructors
1 parent 4dad182 commit e039048

File tree

11 files changed

+964
-298
lines changed

11 files changed

+964
-298
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
2+
resolver = "2"
23

34
members = [
45
"lib",

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,81 @@ For versions past 1.0.0, a change in the MSRV can be done in a minor version inc
5858
for versions before 1.0.0, a change in the MSRV can be done in a patch version increment (0.1.3 -> 0.1.4).
5959

6060

61+
## Development
62+
63+
### Testing
64+
65+
This crate contains unit tests and integration tests.
66+
The unit tests are run with `cargo test --lib` and do not require a running Neo4j instance.
67+
The integration tests are run with `cargo test` and require a running Neo4j instance.
68+
69+
#### Running the integration tests
70+
71+
To run the tests, you need to have either docker or an existing Neo4j instance running.
72+
Docker is recommended since the tests don't necessarily clean up after themselves.
73+
74+
##### Using Docker
75+
76+
To run the tests with docker, you need to have docker installed and running.
77+
You can control the version of Neo4j that is used by setting the `NEO4J_VERSION_TAG` environment variable.
78+
The default version is `4.2`.
79+
The tests will use the official `neo4j` docker image, with the provided version as tag.
80+
81+
You might run into panics or test failures with the message 'failed to start container'.
82+
In that case, try to pull the image first before running the tests with `docker pull neo4j:$NEO4J_VERSION_TAG`.
83+
84+
This could happend if you are on a machine with an architecture that is not supported by the image, e.g. `arm64` like the Apple silicon Macs.
85+
In that case, pulling the image will fail with a message like 'no matching manifest for linux/arm64/v8'.
86+
You need to use the `--platform` flag to pull the image for a different architecture, e.g. `docker pull --platform linux/amd64 neo4j:$NEO4J_VERSION_TAG`.
87+
There is an experimental option in docker to use Rosetta to run those images, so that tests don't take forever to run (please check the docker documentation).
88+
89+
You could also use a newer neo4j version like `4.4` instead, which has support for `arm64` architecture.
90+
91+
##### Using an existing Neo4j instance
92+
93+
To run the tests with an existing Neo4j instance, you need to have the `NEO4J_TEST_URI` environment variable set to the connection string, e.g. `neo4j+s://42421337thisisnotarealinstance.databases.neo4j.io`.
94+
The default user is `neo4j`, but it can be changed with the `NEO4J_TEST_USER` environment variable.
95+
The default password is `neo`, but it can be changed with the `NEO4J_TEST_PASS` environment variable.
96+
97+
Some tests might run different queries depending on the Neo4j version.
98+
You can use the `NEO4J_VERSION_TAG` environment variable to set the version of the Neo4j instance.
99+
100+
It is recommended to only run a single integration test and manually clean up the database after the test.
101+
102+
```sh
103+
env NEO4J_TEST_URI=neo4j+s://42421337thisisnotarealinstance.databases.neo4j.io NEO4J_TEST_USER=neo4j NEO4J_TEST_PASS=supersecret NEO4J_VERSION_TAG=5.8 cargo test --test <name of the integration test, see the file names in lib/tests/>
104+
```
105+
106+
### Updating Cargo.lock files for CI
107+
108+
We have CI tests that verify the MSRV as well as the minimal version of the dependencies.
109+
The minimal versions are the lowest version that still satisfies the Cargo.toml entries, instead of the default of the highest version.
110+
111+
If you change anything in the Cargo.toml, you need to update the Cargo.lock files for CI.
112+
113+
It is recommended to close all editors, or more sepcifically, all rust-analyzer instances for this project before running the commands below.
114+
115+
#### Update `ci/Cargo.lock.msrv`
116+
117+
```bash
118+
rm Cargo.lock
119+
cargo +1.60.0 test --no-run
120+
# If there are errors, update Cargo.toml to fix and try again from the top.
121+
# You might have to downgrade or remove certain crates to hit the MSRV,
122+
# or suggest an increase in the MSRV.
123+
cp Cargo.lock ci/Cargo.lock.msrv
124+
```
125+
126+
#### Update `ci/Cargo.lock.min`
127+
128+
```bash
129+
rm Cargo.lock
130+
RUST_LOG=debug cargo +nightly -Z minimal-versions test --no-run
131+
# If there are errors, update Cargo.toml to fix and try again from the top.
132+
cp Cargo.lock ci/Cargo.lock.min
133+
```
134+
135+
61136
## License
62137

63138
Neo4rs is licensed under either of the following, at your option:

0 commit comments

Comments
 (0)