Skip to content

Commit

Permalink
Created parameterized integration_client_async
Browse files Browse the repository at this point in the history
  • Loading branch information
criminosis committed Nov 13, 2024
1 parent 85a58f1 commit a1bbe79
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 204 deletions.
72 changes: 42 additions & 30 deletions gremlin-client/tests/integration_client_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ mod common;
mod aio {

use gremlin_client::{aio::GremlinClient, ConnectionOptions, GremlinError, TlsOptions};
use gremlin_client::{Edge, GValue, Map, Vertex};
use gremlin_client::{Edge, GValue, IoProtocol, Map, Vertex};

use rstest::*;
use rstest_reuse::{self, *};

use super::common::aio::{connect, create_edge, create_vertex, drop_vertices};
use crate::common;

use super::common::aio::{connect, create_edge, create_vertex, drop_vertices, connect_serializer};
#[cfg(feature = "async-std-runtime")]
use async_std::prelude::*;

#[cfg(feature = "tokio-runtime")]
use tokio_stream::StreamExt;

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_client_connection_ok() {
connect().await;
}

#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_ok_credentials() {
async fn test_ok_credentials(protocol: IoProtocol) {
let client = GremlinClient::connect(
ConnectionOptions::builder()
.host("localhost")
Expand All @@ -32,6 +32,8 @@ mod aio {
.tls_options(TlsOptions {
accept_invalid_certs: true,
})
.serializer(protocol.clone())
.deserializer(protocol)
.build(),
)
.await
Expand All @@ -41,10 +43,11 @@ mod aio {
assert!(result.is_ok(), "{:?}", result);
}

#[apply(common::serializers)]
#[cfg(feature = "async-std-runtime")]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_empty_query() {
let graph = connect().await;
async fn test_empty_query(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;

assert_eq!(
0,
Expand All @@ -57,10 +60,11 @@ mod aio {
)
}

#[apply(common::serializers)]
#[cfg(feature = "async-std-runtime")]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_session_empty_query() {
let mut graph = connect().await;
async fn test_session_empty_query(protocol: IoProtocol) {
let mut graph = connect_serializer(protocol).await;
let mut sessioned_graph = graph
.create_session("test-session".to_string())
.await
Expand All @@ -82,10 +86,11 @@ mod aio {
.expect("It should close the session.");
}

#[apply(common::serializers)]
#[cfg(feature = "async-std-runtime")]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_keep_alive_query() {
let graph = connect().await;
async fn test_keep_alive_query(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;

assert_eq!(
0,
Expand All @@ -110,10 +115,11 @@ mod aio {
)
}

#[apply(common::serializers)]
#[cfg(feature = "async-std-runtime")]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_partial_content() {
let graph = connect().await;
async fn test_partial_content(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;

drop_vertices(&graph, "Partial")
.await
Expand All @@ -137,10 +143,11 @@ mod aio {
);
}

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_wrong_query() {
let error = connect()
async fn test_wrong_query(protocol: IoProtocol) {
let error = connect_serializer(protocol)
.await
.execute("g.V", &[])
.await
Expand All @@ -155,10 +162,11 @@ mod aio {
}
}

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_wrong_alias() {
let error = connect()
async fn test_wrong_alias(protocol: IoProtocol) {
let error = connect_serializer(protocol)
.await
.alias("foo")
.execute("g.V()", &[])
Expand All @@ -174,11 +182,11 @@ mod aio {
}
}

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]

async fn test_vertex_query() {
let graph = connect().await;
async fn test_vertex_query(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;
let vertices = graph
.execute(
"g.V().hasLabel('person').has('name',name)",
Expand All @@ -194,10 +202,12 @@ mod aio {

assert_eq!("person", vertices[0].label());
}

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_edge_query() {
let graph = connect().await;
async fn test_edge_query(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;
let edges = graph
.execute("g.E().hasLabel('knows').limit(1)", &[])
.await
Expand All @@ -211,10 +221,11 @@ mod aio {
assert_eq!("knows", edges[0].label());
}

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_vertex_creation() {
let graph = connect().await;
async fn test_vertex_creation(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;
let mark = create_vertex(&graph, "mark").await;

assert_eq!("person", mark.label());
Expand All @@ -237,10 +248,11 @@ mod aio {
);
}

#[apply(common::serializers)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
async fn test_edge_creation() {
let graph = connect().await;
async fn test_edge_creation(protocol: IoProtocol) {
let graph = connect_serializer(protocol).await;
let mark = create_vertex(&graph, "mark").await;
let frank = create_vertex(&graph, "frank").await;

Expand Down
174 changes: 0 additions & 174 deletions gremlin-client/tests/integration_client_async_v2.rs

This file was deleted.

0 comments on commit a1bbe79

Please sign in to comment.