From 99b663e3a7becf007f9d06471496b8814fd67d77 Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 20 Sep 2024 20:45:20 +0900 Subject: [PATCH] chore(test): Move integration test for tonic-web to tests directory (#1927) --- Cargo.toml | 2 +- {tonic-web/tests/integration => tests/web}/Cargo.toml | 8 ++++---- {tonic-web/tests/integration => tests/web}/LICENSE | 0 {tonic-web/tests/integration => tests/web}/build.rs | 0 .../tests/integration => tests/web}/proto/test.proto | 0 {tonic-web/tests/integration => tests/web}/src/lib.rs | 0 {tonic-web/tests/integration => tests/web}/tests/grpc.rs | 4 ++-- .../tests/integration => tests/web}/tests/grpc_web.rs | 8 ++++---- 8 files changed, 11 insertions(+), 11 deletions(-) rename {tonic-web/tests/integration => tests/web}/Cargo.toml (73%) rename {tonic-web/tests/integration => tests/web}/LICENSE (100%) rename {tonic-web/tests/integration => tests/web}/build.rs (100%) rename {tonic-web/tests/integration => tests/web}/proto/test.proto (100%) rename {tonic-web/tests/integration => tests/web}/src/lib.rs (100%) rename {tonic-web/tests/integration => tests/web}/tests/grpc.rs (97%) rename {tonic-web/tests/integration => tests/web}/tests/grpc_web.rs (95%) diff --git a/Cargo.toml b/Cargo.toml index 77b8463fa..ee6337877 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ members = [ "tests/stream_conflict", "tests/root-crate-path", "tests/compression", - "tonic-web/tests/integration", + "tests/web", "tests/service_named_result", "tests/use_arc_self", "tests/default_stubs", diff --git a/tonic-web/tests/integration/Cargo.toml b/tests/web/Cargo.toml similarity index 73% rename from tonic-web/tests/integration/Cargo.toml rename to tests/web/Cargo.toml index 8341c927b..73d3f0d8d 100644 --- a/tonic-web/tests/integration/Cargo.toml +++ b/tests/web/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Juan Alvarez "] edition = "2021" -name = "integration" +name = "test_web" publish = false version = "0.1.0" license = "MIT" @@ -16,10 +16,10 @@ hyper-util = "0.1" prost = "0.13" tokio = { version = "1", features = ["macros", "rt", "net"] } tokio-stream = { version = "0.1", features = ["net"] } -tonic = { path = "../../../tonic" } +tonic = { path = "../../tonic" } [dev-dependencies] -tonic-web = { path = "../../../tonic-web" } +tonic-web = { path = "../../tonic-web" } [build-dependencies] -tonic-build = { path = "../../../tonic-build" } +tonic-build = { path = "../../tonic-build" } diff --git a/tonic-web/tests/integration/LICENSE b/tests/web/LICENSE similarity index 100% rename from tonic-web/tests/integration/LICENSE rename to tests/web/LICENSE diff --git a/tonic-web/tests/integration/build.rs b/tests/web/build.rs similarity index 100% rename from tonic-web/tests/integration/build.rs rename to tests/web/build.rs diff --git a/tonic-web/tests/integration/proto/test.proto b/tests/web/proto/test.proto similarity index 100% rename from tonic-web/tests/integration/proto/test.proto rename to tests/web/proto/test.proto diff --git a/tonic-web/tests/integration/src/lib.rs b/tests/web/src/lib.rs similarity index 100% rename from tonic-web/tests/integration/src/lib.rs rename to tests/web/src/lib.rs diff --git a/tonic-web/tests/integration/tests/grpc.rs b/tests/web/tests/grpc.rs similarity index 97% rename from tonic-web/tests/integration/tests/grpc.rs rename to tests/web/tests/grpc.rs index 98eca1f92..ecd17988e 100644 --- a/tonic-web/tests/integration/tests/grpc.rs +++ b/tests/web/tests/grpc.rs @@ -9,8 +9,8 @@ use tokio_stream::{self as stream, StreamExt}; use tonic::transport::{Channel, Error, Server}; use tonic::{Response, Streaming}; -use integration::pb::{test_client::TestClient, test_server::TestServer, Input}; -use integration::Svc; +use test_web::pb::{test_client::TestClient, test_server::TestServer, Input}; +use test_web::Svc; use tonic_web::GrpcWebLayer; #[tokio::test] diff --git a/tonic-web/tests/integration/tests/grpc_web.rs b/tests/web/tests/grpc_web.rs similarity index 95% rename from tonic-web/tests/integration/tests/grpc_web.rs rename to tests/web/tests/grpc_web.rs index 2c57f2680..1c00773a3 100644 --- a/tonic-web/tests/integration/tests/grpc_web.rs +++ b/tests/web/tests/grpc_web.rs @@ -14,8 +14,8 @@ use tokio_stream::wrappers::TcpListenerStream; use tonic::body::BoxBody; use tonic::transport::Server; -use integration::pb::{test_server::TestServer, Input, Output}; -use integration::Svc; +use test_web::pb::{test_server::TestServer, Input, Output}; +use test_web::Svc; use tonic::Status; use tonic_web::GrpcWebLayer; @@ -117,7 +117,7 @@ fn build_request(base_uri: String, content_type: &str, accept: &str) -> Request< let bytes = match content_type { "grpc-web" => encode_body(), - "grpc-web-text" => integration::util::base64::STANDARD + "grpc-web-text" => test_web::util::base64::STANDARD .encode(encode_body()) .into(), _ => panic!("invalid content type {}", content_type), @@ -139,7 +139,7 @@ async fn decode_body(body: Incoming, content_type: &str) -> (Output, Bytes) { let mut body = body.collect().await.unwrap().to_bytes(); if content_type == "application/grpc-web-text+proto" { - body = integration::util::base64::STANDARD + body = test_web::util::base64::STANDARD .decode(body) .unwrap() .into()