Skip to content

Commit

Permalink
Rename event::mock() to event()
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeHahn committed Jul 10, 2020
1 parent 33d5829 commit ae68425
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 92 deletions.
8 changes: 4 additions & 4 deletions tracing-attributes/tests/async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn async_fn_only_enters_for_polls() {
let (subscriber, handle) = subscriber::expect()
.new_span(span("test_async_fn"))
.enter(span("test_async_fn"))
.event(event::mock().with_fields(field("awaiting").with_value(&true)))
.event(event().with_fields(field("awaiting").with_value(&true)))
.exit(span("test_async_fn"))
.enter(span("test_async_fn"))
.exit(span("test_async_fn"))
Expand Down Expand Up @@ -51,7 +51,7 @@ fn async_fn_nested() {
.enter(span1.clone())
.new_span(span2.clone())
.enter(span2.clone())
.event(event::mock().with_fields(field("nested").with_value(&true)))
.event(event().with_fields(field("nested").with_value(&true)))
.exit(span2.clone())
.drop_span(span2)
.exit(span1.clone())
Expand Down Expand Up @@ -130,12 +130,12 @@ fn async_fn_with_async_trait() {
.enter(span1.clone())
.new_span(span3.clone())
.enter(span3.clone())
.event(event::mock().with_fields(field("val").with_value(&2u64)))
.event(event().with_fields(field("val").with_value(&2u64)))
.exit(span3.clone())
.drop_span(span3)
.new_span(span2.clone().with_field(field("self")))
.enter(span2.clone())
.event(event::mock().with_fields(field("val").with_value(&5u64)))
.event(event().with_fields(field("val").with_value(&5u64)))
.exit(span2.clone())
.drop_span(span2)
.exit(span1.clone())
Expand Down
6 changes: 3 additions & 3 deletions tracing-attributes/tests/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn test() {
let (subscriber, handle) = subscriber::expect()
.new_span(span.clone())
.enter(span.clone())
.event(event::mock().at_level(Level::ERROR))
.event(event().at_level(Level::ERROR))
.exit(span.clone())
.drop_span(span)
.done()
Expand All @@ -46,13 +46,13 @@ fn test_async() {
.new_span(span.clone())
.enter(span.clone())
.event(
event::mock()
event()
.with_fields(field("awaiting").with_value(&true))
.at_level(Level::TRACE),
)
.exit(span.clone())
.enter(span.clone())
.event(event::mock().at_level(Level::ERROR))
.event(event().at_level(Level::ERROR))
.exit(span.clone())
.drop_span(span)
.done()
Expand Down
18 changes: 5 additions & 13 deletions tracing-subscriber/tests/field_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ use tracing_test::*;
fn field_filter_events() {
let filter: EnvFilter = "[{thing}]=debug".parse().expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(
event::mock()
.at_level(Level::INFO)
.with_fields(field("thing")),
)
.event(
event::mock()
.at_level(Level::DEBUG)
.with_fields(field("thing")),
)
.event(event().at_level(Level::INFO).with_fields(field("thing")))
.event(event().at_level(Level::DEBUG).with_fields(field("thing")))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand All @@ -39,7 +31,7 @@ fn field_filter_spans() {
let (subscriber, finished) = subscriber::expect()
.enter(span("span1"))
.event(
event::mock()
event()
.at_level(Level::INFO)
.with_fields(field("something")),
)
Expand All @@ -48,7 +40,7 @@ fn field_filter_spans() {
.exit(span("span2"))
.enter(span("span3"))
.event(
event::mock()
event()
.at_level(Level::DEBUG)
.with_fields(field("something")),
)
Expand Down Expand Up @@ -84,7 +76,7 @@ fn record_after_created() {
.exit(span("span"))
.record(span("span"), field("enabled").with_value(&true))
.enter(span("span"))
.event(event::mock().at_level(Level::DEBUG))
.event(event().at_level(Level::DEBUG))
.exit(span("span"))
.done()
.run_with_handle();
Expand Down
42 changes: 21 additions & 21 deletions tracing-subscriber/tests/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use tracing_test::*;
fn level_filter_event() {
let filter: EnvFilter = "info".parse().expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::INFO))
.event(event::mock().at_level(Level::WARN))
.event(event::mock().at_level(Level::ERROR))
.event(event().at_level(Level::INFO))
.event(event().at_level(Level::WARN))
.event(event().at_level(Level::ERROR))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand Down Expand Up @@ -50,11 +50,11 @@ fn same_name_spans() {
fn level_filter_event_with_target() {
let filter: EnvFilter = "info,stuff=debug".parse().expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::INFO))
.event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
.event(event::mock().at_level(Level::WARN).with_target("stuff"))
.event(event::mock().at_level(Level::ERROR))
.event(event::mock().at_level(Level::ERROR).with_target("stuff"))
.event(event().at_level(Level::INFO))
.event(event().at_level(Level::DEBUG).with_target("stuff"))
.event(event().at_level(Level::WARN).with_target("stuff"))
.event(event().at_level(Level::ERROR))
.event(event().at_level(Level::ERROR).with_target("stuff"))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand All @@ -79,11 +79,11 @@ fn not_order_dependent() {

let filter: EnvFilter = "stuff=debug,info".parse().expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::INFO))
.event(event::mock().at_level(Level::DEBUG).with_target("stuff"))
.event(event::mock().at_level(Level::WARN).with_target("stuff"))
.event(event::mock().at_level(Level::ERROR))
.event(event::mock().at_level(Level::ERROR).with_target("stuff"))
.event(event().at_level(Level::INFO))
.event(event().at_level(Level::DEBUG).with_target("stuff"))
.event(event().at_level(Level::WARN).with_target("stuff"))
.event(event().at_level(Level::ERROR))
.event(event().at_level(Level::ERROR).with_target("stuff"))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand Down Expand Up @@ -113,8 +113,8 @@ fn add_directive_enables_event() {
filter = filter.add_directive("hello=trace".parse().expect("directive should parse"));

let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::INFO).with_target("hello"))
.event(event::mock().at_level(Level::TRACE).with_target("hello"))
.event(event().at_level(Level::INFO).with_target("hello"))
.event(event().at_level(Level::TRACE).with_target("hello"))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand All @@ -133,17 +133,17 @@ fn span_name_filter_is_dynamic() {
.parse()
.expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::INFO))
.event(event().at_level(Level::INFO))
.enter(span("cool_span"))
.event(event::mock().at_level(Level::DEBUG))
.event(event().at_level(Level::DEBUG))
.enter(span("uncool_span"))
.event(event::mock().at_level(Level::WARN))
.event(event::mock().at_level(Level::DEBUG))
.event(event().at_level(Level::WARN))
.event(event().at_level(Level::DEBUG))
.exit(span("uncool_span"))
.exit(span("cool_span"))
.enter(span("uncool_span"))
.event(event::mock().at_level(Level::WARN))
.event(event::mock().at_level(Level::ERROR))
.event(event().at_level(Level::WARN))
.event(event().at_level(Level::ERROR))
.exit(span("uncool_span"))
.done()
.run_with_handle();
Expand Down
6 changes: 3 additions & 3 deletions tracing-subscriber/tests/filter_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn log_is_enabled() {
.parse()
.expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::INFO))
.event(event::mock().at_level(Level::WARN))
.event(event::mock().at_level(Level::ERROR))
.event(event().at_level(Level::INFO))
.event(event().at_level(Level::WARN))
.event(event().at_level(Level::ERROR))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand Down
16 changes: 4 additions & 12 deletions tracing-subscriber/tests/same_len_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use tracing_test::*;
fn same_length_targets() {
let filter: EnvFilter = "foo=trace,bar=trace".parse().expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(event::mock().at_level(Level::TRACE))
.event(event::mock().at_level(Level::TRACE))
.event(event().at_level(Level::TRACE))
.event(event().at_level(Level::TRACE))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand All @@ -29,16 +29,8 @@ fn same_num_fields_event() {
.parse()
.expect("filter should parse");
let (subscriber, finished) = subscriber::expect()
.event(
event::mock()
.at_level(Level::TRACE)
.with_fields(field("foo")),
)
.event(
event::mock()
.at_level(Level::TRACE)
.with_fields(field("bar")),
)
.event(event().at_level(Level::TRACE).with_fields(field("foo")))
.event(event().at_level(Level::TRACE).with_fields(field("bar")))
.done()
.run_with_handle();
let subscriber = subscriber.with(filter);
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tracing_test::*;
fn init_ext_works() {
let (subscriber, finished) = subscriber::expect()
.event(
event::mock()
event()
.at_level(tracing::Level::INFO)
.with_target("init_works"),
)
Expand Down
2 changes: 1 addition & 1 deletion tracing-test/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct MockEvent {
metadata: metadata::Expect,
}

pub fn mock() -> MockEvent {
pub fn event() -> MockEvent {
MockEvent {
..Default::default()
}
Expand Down
1 change: 1 addition & 0 deletions tracing-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub mod metadata;
pub mod span;
pub mod subscriber;

pub use event::event;
pub use field::field;
pub use span::{anonymous_span, span};

Expand Down
Loading

0 comments on commit ae68425

Please sign in to comment.