Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Jan 27, 2022
1 parent e50c197 commit 2f6c237
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
10 changes: 5 additions & 5 deletions tests/propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn basic() {
let data = "1-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=-ZXhhbXBsZS5jb206ODA4MA==";
let res = decode_propagation(data).unwrap();

assert_eq!(res.do_sample, true);
assert!(res.do_sample);
assert_eq!(res.parent_trace_id, "1");
assert_eq!(res.parent_trace_segment_id, "5");
assert_eq!(res.parent_span_id, 3);
Expand All @@ -50,23 +50,23 @@ fn less_field() {
let data = "1-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=";
let res = decode_propagation(data);

assert_eq!(res.is_err(), true);
assert!(res.is_err());
}

#[test]
fn more_field() {
let data = "1-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=-ZXhhbXBsZS5jb206ODA4MA==-hogehoge";
let res = decode_propagation(data);

assert_eq!(res.is_err(), true);
assert!(res.is_err());
}

#[test]
fn invalid_sample() {
let data = "3-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=-ZXhhbXBsZS5jb206ODA4MA==";
let res = decode_propagation(data);

assert_eq!(res.is_err(), true);
assert!(res.is_err());
}

#[test]
Expand All @@ -75,7 +75,7 @@ fn basic_encode() {
let tc = TracingContext::default_internal(Arc::new(time_fetcher), "mesh", "instance");
let res = encode_propagation(&tc, "/api/v1/health", "example.com:8080");
let res2 = decode_propagation(&res).unwrap();
assert_eq!(true, res2.do_sample);
assert!(res2.do_sample);
assert_eq!("/api/v1/health", res2.destination_endpoint);
assert_eq!("example.com:8080", res2.destination_address)
}
28 changes: 12 additions & 16 deletions tests/trace_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ fn create_span() {

{
let mut span1 = context.create_entry_span("op1").unwrap();
let mut logs = Vec::<(&str, &str)>::new();
logs.push(("hoge", "fuga"));
logs.push(("hoge2", "fuga2"));
let logs = vec![("hoge", "fuga"), ("hoge2", "fuga2")];
let expected_log_message = logs
.to_owned()
.into_iter()
Expand All @@ -80,15 +78,13 @@ fn create_span() {
}
})
.collect();
let mut expected_log = Vec::<Log>::new();
expected_log.push(Log {
let expected_log = vec![Log {
time: 100,
data: expected_log_message,
});
}];
span1.add_log(logs);

let mut tags = Vec::<(&str, &str)>::new();
tags.push(("hoge", "fuga"));
let tags = vec![("hoge", "fuga")];
let expected_tags = tags
.to_owned()
.into_iter()
Expand All @@ -100,7 +96,7 @@ fn create_span() {
}
})
.collect();
span1.add_tag(tags[0].clone());
span1.add_tag(tags[0]);

let span1_expected = SpanObject {
span_id: 1,
Expand All @@ -124,7 +120,7 @@ fn create_span() {

{
let span2 = context.create_entry_span("op2");
assert_eq!(span2.is_err(), true);
assert!(span2.is_err());
}

{
Expand All @@ -150,11 +146,11 @@ fn create_span() {
}

let segment = context.convert_segment_object();
assert_eq!(segment.trace_id.len() != 0, true);
assert_eq!(segment.trace_segment_id.len() != 0, true);
assert_ne!(segment.trace_id.len(), 0);
assert_ne!(segment.trace_segment_id.len(), 0);
assert_eq!(segment.service, "service");
assert_eq!(segment.service_instance, "instance");
assert_eq!(segment.is_size_limited, false);
assert!(!segment.is_size_limited);
}

#[test]
Expand All @@ -170,11 +166,11 @@ fn create_span_from_context() {
);

let segment = context.convert_segment_object();
assert_eq!(segment.trace_id.len() != 0, true);
assert_eq!(segment.trace_segment_id.len() != 0, true);
assert_ne!(segment.trace_id.len(), 0);
assert_ne!(segment.trace_segment_id.len(), 0);
assert_eq!(segment.service, "service2");
assert_eq!(segment.service_instance, "instance2");
assert_eq!(segment.is_size_limited, false);
assert!(!segment.is_size_limited);
}

#[test]
Expand Down

0 comments on commit 2f6c237

Please sign in to comment.