Skip to content

Commit

Permalink
update deps and add test for license
Browse files Browse the repository at this point in the history
  • Loading branch information
atimin committed Mar 1, 2024
1 parent 91628da commit 5e7fc65
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ jobs:
- rust_fmt
steps:
- uses: actions/checkout@v4
- name: Generate license
run: echo '${{secrets.LICENSE_KEY}}' > lic.key
- name: Run Database
run: docker run --network=host -v ${PWD}/misc:/misc --env RS_API_TOKEN=TOKEN -d ${{env.REGISTRY_IMAGE}}
run: docker run --network=host -v ${PWD}/misc:/misc
--env RS_API_TOKEN=TOKEN
--env RS_LICENSE_PATH=/misc/lic.key -d ${{env.REGISTRY_IMAGE}}
- name: Run Client SDK tests
run: RS_API_TOKEN=TOKEN cargo test -- --test-threads=1
run: RS_API_TOKEN=TOKEN RS_LICENSE_PATH=lic.key cargo test -- --test-threads=1

sdk_examples:
name: Client SDK Examples
Expand Down
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "reduct-rs"

version = "1.8.0"
version = "1.9.0-dev"
authors =["Alexey Timin <atimin@reduct.store>"]
edition = "2021"
rust-version = "1.75.0"
Expand All @@ -19,11 +19,12 @@ categories = ["database"]
crate-type = ["lib"]

[dependencies]
reduct-base = { version = "1.8.0" }
reduct-base = {git = "https://github.com/reductstore/reductstore.git", branch = "main"}
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "stream"] }
rustls = "0.22.2"
http = "1.0.0"
rustls = "0.23"
chrono = { version = "0.4.11", features = ["serde"] }
bytes = "1.4.0"
futures = "0.3.17"
Expand All @@ -35,3 +36,4 @@ tokio = { version = "1.0", features = ["macros"] }
[dev-dependencies]
tokio = { version = "1.0", features = ["test-util", "rt-multi-thread"] }
rstest = "0.18.1"
test-with = "0.12.5"
11 changes: 11 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,20 @@ pub(crate) mod tests {
#[rstest]
#[tokio::test]
async fn test_server_info(#[future] client: ReductClient) {
// we don't need to check every field because we share the same struct with the server
let info = client.await.server_info().await.unwrap();
assert!(info.version.starts_with("1."));
assert!(info.bucket_count >= 2);

assert!(info.license.unwrap().licensee == "ReductStore");
}

#[test_with::env("RS_LICENSE_PATH")]
#[rstest]
#[tokio::test]
async fn test_server_license(#[future] client: ReductClient) {
let info = client.await.server_info().await.unwrap();
assert_eq!(info.license.unwrap().licensee, "ReductStore");
}

#[rstest]
Expand Down
12 changes: 11 additions & 1 deletion src/record/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bytes::Bytes;
use bytes::BytesMut;
use futures::Stream;
use futures_util::{pin_mut, StreamExt};
use reduct_base::batch::{parse_batched_header, sort_headers_by_name, RecordHeader};
use reduct_base::batch::{parse_batched_header, RecordHeader};
use reduct_base::error::ReductError;
use reduct_base::msg::entry_api::QueryInfo;
use reduct_base::Labels;
Expand Down Expand Up @@ -222,6 +222,16 @@ impl QueryBuilder {
}
}

fn sort_headers_by_name(headers: &HeaderMap) -> Vec<(String, HeaderValue)> {
let mut sorted_headers: Vec<_> = headers
.clone()
.into_iter()
.map(|(key, value)| (key.unwrap().as_str().to_string(), value))
.collect();
sorted_headers.sort_by(|(name1, _), (name2, _)| name1.cmp(name2));
sorted_headers
}

async fn parse_batched_records(
headers: HeaderMap,
rx: Receiver<Bytes>,
Expand Down

0 comments on commit 5e7fc65

Please sign in to comment.