1+ #![ warn( clippy:: pedantic) ]
2+
13// should match vector-unit-test-tests feature
24#[ cfg( all(
35 test,
@@ -64,6 +66,8 @@ pub struct UnitTestResult {
6466}
6567
6668impl UnitTest {
69+ // https://github.com/vectordotdev/vector/issues/23659
70+ #[ allow( clippy:: missing_panics_doc, reason = "Panic documentation deferred" ) ]
6771 pub async fn run ( self ) -> UnitTestResult {
6872 let diff = config:: ConfigDiff :: initial ( & self . config ) ;
6973 let ( topology, _) = RunningTopology :: start_validated ( self . config , diff, self . pieces )
@@ -102,6 +106,8 @@ fn init_log_schema_from_paths(
102106 Ok ( ( ) )
103107}
104108
109+ // https://github.com/vectordotdev/vector/issues/23659
110+ #[ allow( clippy:: missing_errors_doc, reason = "Error documentation deferred" ) ]
105111pub async fn build_unit_tests_main (
106112 paths : & [ ConfigPath ] ,
107113 signal_handler : & mut signal:: SignalHandler ,
@@ -121,12 +127,14 @@ pub async fn build_unit_tests_main(
121127 build_unit_tests ( config_builder) . await
122128}
123129
130+ // https://github.com/vectordotdev/vector/issues/23659
131+ #[ allow( clippy:: missing_errors_doc, reason = "Error documentation deferred" ) ]
124132pub async fn build_unit_tests (
125133 mut config_builder : ConfigBuilder ,
126134) -> Result < Vec < UnitTest > , Vec < String > > {
127135 // Sanitize config by removing existing sources and sinks
128- config_builder. sources = Default :: default ( ) ;
129- config_builder. sinks = Default :: default ( ) ;
136+ config_builder. sources = IndexMap :: default ( ) ;
137+ config_builder. sinks = IndexMap :: default ( ) ;
130138
131139 let test_definitions = std:: mem:: take ( & mut config_builder. tests ) ;
132140 let mut tests = Vec :: new ( ) ;
@@ -172,6 +180,9 @@ pub struct UnitTestBuildMetadata {
172180}
173181
174182impl UnitTestBuildMetadata {
183+ // https://github.com/vectordotdev/vector/issues/23659
184+ #[ allow( clippy:: missing_errors_doc, reason = "Error documentation deferred" ) ]
185+ #[ allow( clippy:: missing_panics_doc, reason = "Panic documentation deferred" ) ]
175186 pub fn initialize ( config_builder : & mut ConfigBuilder ) -> Result < Self , Vec < String > > {
176187 // A unique id used to name test sources and sinks to avoid name clashes
177188 let random_id = Uuid :: new_v4 ( ) . to_string ( ) ;
@@ -189,7 +200,7 @@ impl UnitTestBuildMetadata {
189200
190201 // Map a test source to every transform
191202 let mut template_sources = IndexMap :: new ( ) ;
192- for ( key, transform) in config_builder. transforms . iter_mut ( ) {
203+ for ( key, transform) in & mut config_builder. transforms {
193204 let test_source_id = source_ids
194205 . get ( key)
195206 . expect ( "Missing test source for a transform" )
@@ -235,6 +246,9 @@ impl UnitTestBuildMetadata {
235246 }
236247
237248 /// Convert test inputs into sources for use in a unit testing topology
249+ // https://github.com/vectordotdev/vector/issues/23659
250+ #[ allow( clippy:: missing_errors_doc, reason = "Error documentation deferred" ) ]
251+ #[ allow( clippy:: missing_panics_doc, reason = "Panic documentation deferred" ) ]
238252 pub fn hydrate_into_sources (
239253 & self ,
240254 inputs : & [ TestInput ] ,
@@ -268,6 +282,9 @@ impl UnitTestBuildMetadata {
268282 }
269283
270284 /// Convert test outputs into sinks for use in a unit testing topology
285+ // https://github.com/vectordotdev/vector/issues/23659
286+ #[ allow( clippy:: missing_errors_doc, reason = "Error documentation deferred" ) ]
287+ #[ allow( clippy:: missing_panics_doc, reason = "Panic documentation deferred" ) ]
271288 pub fn hydrate_into_sinks (
272289 & self ,
273290 test_name : & str ,
@@ -296,7 +313,7 @@ impl UnitTestBuildMetadata {
296313 let sink_ids = ids. clone ( ) ;
297314 let sink_config = UnitTestSinkConfig {
298315 test_name : test_name. to_string ( ) ,
299- transform_ids : ids. iter ( ) . map ( |id| id . to_string ( ) ) . collect ( ) ,
316+ transform_ids : ids. iter ( ) . map ( std :: string :: ToString :: to_string) . collect ( ) ,
300317 result_tx : Arc :: new ( Mutex :: new ( Some ( tx) ) ) ,
301318 check : UnitTestSinkCheck :: Checks {
302319 conditions : built. conditions ,
@@ -327,7 +344,7 @@ impl UnitTestBuildMetadata {
327344 . map ( |( transform_ids, sink_config) | {
328345 let transform_ids_str = transform_ids
329346 . iter ( )
330- . map ( |s| s . to_string ( ) )
347+ . map ( std :: string :: ToString :: to_string)
331348 . collect :: < Vec < _ > > ( ) ;
332349 let sink_ids = transform_ids
333350 . iter ( )
@@ -446,7 +463,7 @@ async fn build_unit_test(
446463 config_builder. global . wildcard_matching . unwrap_or_default ( ) ,
447464 ) ?;
448465 let valid_outputs = graph. output_map ( ) ?;
449- for ( _, transform) in config_builder. transforms . iter_mut ( ) {
466+ for ( _, transform) in & mut config_builder. transforms {
450467 let inputs = std:: mem:: take ( & mut transform. inputs ) ;
451468 transform. inputs = inputs
452469 . into_iter ( )
@@ -476,7 +493,7 @@ async fn build_unit_test(
476493/// consumed but its other outputs are left unconsumed.
477494///
478495/// To avoid warning logs that occur when building such topologies, we construct
479- /// a NoOp sink here whose sole purpose is to consume any "loose end" outputs.
496+ /// a ` NoOp` sink here whose sole purpose is to consume any "loose end" outputs.
480497fn get_loose_end_outputs_sink ( config : & ConfigBuilder ) -> Option < SinkOuter < String > > {
481498 let config = config. clone ( ) ;
482499 let transform_ids = config. transforms . iter ( ) . flat_map ( |( key, transform) | {
@@ -508,7 +525,7 @@ fn get_loose_end_outputs_sink(config: &ConfigBuilder) -> Option<SinkOuter<String
508525 None
509526 } else {
510527 let noop_sink = UnitTestSinkConfig {
511- test_name : "" . to_string ( ) ,
528+ test_name : String :: new ( ) ,
512529 transform_ids : vec ! [ ] ,
513530 result_tx : Arc :: new ( Mutex :: new ( None ) ) ,
514531 check : UnitTestSinkCheck :: NoOp ,
@@ -545,7 +562,7 @@ fn build_and_validate_inputs(
545562 errors. push ( format ! (
546563 "inputs[{index}]: unable to locate target transform '{}'" ,
547564 input. insert_at
548- ) )
565+ ) ) ;
549566 }
550567 }
551568
@@ -562,6 +579,11 @@ pub(super) struct BuiltOutput {
562579 pub ( super ) conditions : Vec < Vec < Condition > > ,
563580}
564581
582+ // https://github.com/vectordotdev/vector/issues/23659
583+ #[ allow(
584+ clippy:: default_trait_access,
585+ reason = "Preserve inferred default types"
586+ ) ]
565587fn build_outputs (
566588 test_outputs : & [ TestOutput ] ,
567589) -> Result < IndexMap < Vec < OutputId > , BuiltOutput > , Vec < String > > {
0 commit comments