Skip to content

Commit

Permalink
chore: Add test to check FILE_DESCRIPTOR_SET is valid (#1217)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Jan 4, 2023
1 parent c772a78 commit 3ee1e6c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions tonic-health/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ tonic = { version = "0.8", path = "../tonic", default-features = false, features
[dev-dependencies]
tokio = {version = "1.0", features = ["rt-multi-thread", "macros"]}
tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost"] }
prost-types = "0.11"
11 changes: 11 additions & 0 deletions tonic-health/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ pub mod proto {

pub const GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET: &[u8] =
include_bytes!("generated/grpc_health_v1.bin");

#[cfg(test)]
mod tests {
use super::GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET;
use prost::Message as _;

#[test]
fn file_descriptor_set_is_valid() {
prost_types::FileDescriptorSet::decode(GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET).unwrap();
}
}
}

pub mod server;
Expand Down
11 changes: 11 additions & 0 deletions tonic-reflection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ pub mod proto {
include!("generated/grpc.reflection.v1alpha.rs");

pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("generated/reflection_v1alpha1.bin");

#[cfg(test)]
mod tests {
use super::FILE_DESCRIPTOR_SET;
use prost::Message as _;

#[test]
fn file_descriptor_set_is_valid() {
prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET).unwrap();
}
}
}

/// Implementation of the server component of gRPC Server Reflection.
Expand Down
11 changes: 11 additions & 0 deletions tonic-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ pub mod pb {

/// Byte encoded FILE_DESCRIPTOR_SET.
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("generated/types.bin");

#[cfg(test)]
mod tests {
use super::FILE_DESCRIPTOR_SET;
use prost::Message as _;

#[test]
fn file_descriptor_set_is_valid() {
prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET).unwrap();
}
}
}

pub use pb::Status;
Expand Down

0 comments on commit 3ee1e6c

Please sign in to comment.