Skip to content

Commit 35e9b17

Browse files
committed
one simple teset
1 parent 786df2d commit 35e9b17

File tree

1 file changed

+45
-0
lines changed
  • opentelemetry-otlp/src/exporter

1 file changed

+45
-0
lines changed

opentelemetry-otlp/src/exporter/mod.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ impl Default for ExportConfig {
9696
#[derive(Error, Debug)]
9797
/// Errors that can occur while building an exporter.
9898
// TODO: Refine and polish this.
99+
// Non-exhaustive to allow for future expansion without breaking changes.
100+
// This could be refined after polishing and finalizing the errors.
101+
#[non_exhaustive]
99102
pub enum ExporterBuildError {
100103
/// Spawning a new thread failed.
101104
#[error("Spawning a new thread failed. Unable to create Reqwest-Blocking client.")]
@@ -336,6 +339,48 @@ mod tests {
336339
assert_eq!(exporter_builder.exporter_config.endpoint, None);
337340
}
338341

342+
#[cfg(any(feature = "http-proto", feature = "http-json"))]
343+
#[test]
344+
fn invalid_http_endpoint() {
345+
use std::time::Duration;
346+
347+
use crate::{ExportConfig, LogExporter, Protocol, WithExportConfig};
348+
349+
let ex_config = ExportConfig {
350+
endpoint: Some("invalid_uri/something".to_string()),
351+
protocol: Protocol::HttpBinary,
352+
timeout: Duration::from_secs(10),
353+
};
354+
355+
let exporter_result = LogExporter::builder()
356+
.with_http()
357+
.with_export_config(ex_config)
358+
.build();
359+
360+
assert!(exporter_result.is_err());
361+
}
362+
363+
#[cfg(feature = "grpc-tonic")]
364+
#[test]
365+
fn invalid_grpc_endpoint() {
366+
use std::time::Duration;
367+
368+
use crate::{ExportConfig, LogExporter, Protocol, WithExportConfig};
369+
370+
let ex_config = ExportConfig {
371+
endpoint: Some("invalid_uri/something".to_string()),
372+
protocol: Protocol::Grpc,
373+
timeout: Duration::from_secs(10),
374+
};
375+
376+
let exporter_result = LogExporter::builder()
377+
.with_tonic()
378+
.with_export_config(ex_config)
379+
.build();
380+
381+
assert!(exporter_result.is_err());
382+
}
383+
339384
#[cfg(feature = "grpc-tonic")]
340385
#[test]
341386
fn test_default_tonic_endpoint() {

0 commit comments

Comments
 (0)