move trace_util test helpers behind a feature flag #461
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
test-utils
.poll_for_mock_hit
andcreate_send_data
functions into test-utils.To limit
trace_test_utils
to only being used in tests your Cargo.toml file should look like:Motivation
Test code shouldn't be available for use outside of tests.
Because the test-utils need to be used in tests both within
trace-utils
and outside oftrace-utils
it limited possible solutions:trace_test_utils
with#[cfg(test)]
at the module export level doesn't work since it prevents these functions from being imported in tests in other crates.trace-utils
when the helper functions return objects defined intrace-utils
. For example, the Rust compiler thinks there is a type mismatch betweendatadog_test_utils::send_data::SendData
(returned by the create_send_data function) and theSendData
type in the send_data.rs unit tests even though they are the same type. No matter how I defined imports, I couldn't get this type mismatch to go away.How to test the change?
Tests that use these helpers still pass.