Rename client to channel
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use structopt::{clap::arg_enum, StructOpt};
|
||||
use tonic_interop::client;
|
||||
use tonic::transport::Channel;
|
||||
|
||||
#[derive(StructOpt)]
|
||||
struct Opts {
|
||||
@@ -25,8 +26,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let addr = "localhost:10000";
|
||||
let origin = http::Uri::from_shared(format!("http://{}", addr).into()).unwrap();
|
||||
|
||||
let mut client = client::create(origin.clone()).await?;
|
||||
let mut unimplemented_client = client::create_unimplemented(origin).await?;
|
||||
let channel = Channel::builder()
|
||||
// .tls(ca)
|
||||
// .tls_override_domain("foo.test.google.fr")
|
||||
.build(origin)?;
|
||||
|
||||
let mut client = client::TestClient::new(channel.clone());
|
||||
let mut unimplemented_client = client::UnimplementedClient::new(channel);
|
||||
|
||||
let mut failures = Vec::new();
|
||||
|
||||
for test_case in test_cases {
|
||||
println!("{:?}:", test_case);
|
||||
@@ -63,9 +71,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
for result in test_results {
|
||||
println!(" {}", result);
|
||||
|
||||
if result.is_failed() {
|
||||
failures.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !failures.is_empty() {
|
||||
println!("{} tests failed", failures.len());
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -1,11 +1,11 @@
|
||||
use crate::{pb::*, test_assert, TestAssertion};
|
||||
use futures_util::{future, stream, SinkExt, StreamExt};
|
||||
use tokio::sync::mpsc;
|
||||
use tonic::transport::Client;
|
||||
use tonic::transport::Channel;
|
||||
use tonic::{metadata::MetadataValue, Code, Request, Response, Status};
|
||||
|
||||
pub type TestClient = TestServiceClient<Client>;
|
||||
pub type UnimplementedClient = UnimplementedServiceClient<Client>;
|
||||
pub type TestClient = TestServiceClient<Channel>;
|
||||
pub type UnimplementedClient = UnimplementedServiceClient<Channel>;
|
||||
|
||||
tonic::client!(service = "grpc.testing.TestService", proto = "crate::pb");
|
||||
tonic::client!(
|
||||
@@ -22,11 +22,11 @@ const SPECIAL_TEST_STATUS_MESSAGE: &'static str =
|
||||
"\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n";
|
||||
|
||||
pub async fn create(origin: http::Uri) -> Result<TestClient, Box<dyn std::error::Error>> {
|
||||
let ca = tokio::fs::read("tonic-interop/data/ca.pem").await?;
|
||||
// let ca = tokio::fs::read("tonic-interop/data/ca.pem").await?;
|
||||
|
||||
let svc = Client::builder()
|
||||
.tls(ca)
|
||||
.tls_override_domain("foo.test.google.fr")
|
||||
let svc = Channel::builder()
|
||||
// .tls(ca)
|
||||
// .tls_override_domain("foo.test.google.fr")
|
||||
.build(origin)?;
|
||||
|
||||
Ok(TestServiceClient::new(svc))
|
||||
@@ -35,11 +35,11 @@ pub async fn create(origin: http::Uri) -> Result<TestClient, Box<dyn std::error:
|
||||
pub async fn create_unimplemented(
|
||||
origin: http::Uri,
|
||||
) -> Result<UnimplementedClient, Box<dyn std::error::Error>> {
|
||||
let ca = tokio::fs::read("tonic-interop/data/ca.pem").await?;
|
||||
// let ca = tokio::fs::read("tonic-interop/data/ca.pem").await?;
|
||||
|
||||
let svc = Client::builder()
|
||||
.tls(ca)
|
||||
.tls_override_domain("foo.test.google.fr")
|
||||
let svc = Channel::builder()
|
||||
// .tls(ca)
|
||||
// .tls_override_domain("foo.test.google.fr")
|
||||
.build(origin)?;
|
||||
|
||||
Ok(UnimplementedServiceClient::new(svc))
|
||||
|
||||
@@ -47,6 +47,15 @@ pub enum TestAssertion {
|
||||
},
|
||||
}
|
||||
|
||||
impl TestAssertion {
|
||||
pub fn is_failed(&self) -> bool {
|
||||
match self {
|
||||
TestAssertion::Failed { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TestAssertion {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use console::{style, Emoji};
|
||||
|
||||
Reference in New Issue
Block a user