@@ -415,32 +415,7 @@ impl Invoke for DscResource {
415415 fn test ( & self , expected : & str ) -> Result < TestResult , DscError > {
416416 debug ! ( "{}" , t!( "dscresources.dscresource.invokeTest" , resource = self . type_name) ) ;
417417 if let Some ( adapter) = & self . require_adapter {
418- let mut configurator = self . clone ( ) . create_config_for_adapter ( adapter, expected) ?;
419- let result = configurator. invoke_test ( ) ?;
420- let TestResult :: Resource ( ref resource_result) = result. results [ 0 ] . result else {
421- return Err ( DscError :: Operation ( t ! ( "dscresources.dscresource.invokeReturnedWrongResult" , operation = "test" , resource = self . type_name) . to_string ( ) ) ) ;
422- } ;
423- let mut desired_state = resource_result. desired_state
424- . as_object ( ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyIncorrectType" , property = "desiredState" , property_type = "object" ) . to_string ( ) ) ) ?
425- . get ( "resources" ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyNotFound" , property = "resources" ) . to_string ( ) ) ) ?
426- . as_array ( ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyIncorrectType" , property = "resources" , property_type = "array" ) . to_string ( ) ) ) ?[ 0 ]
427- . as_object ( ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyIncorrectType" , property = "resources" , property_type = "object" ) . to_string ( ) ) ) ?
428- . get ( "properties" ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyNotFound" , property = "properties" ) . to_string ( ) ) ) ?. clone ( ) ;
429- let actual_state = resource_result. actual_state
430- . as_object ( ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyIncorrectType" , property = "actualState" , property_type = "object" ) . to_string ( ) ) ) ?
431- . get ( "result" ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyNotFound" , property = "result" ) . to_string ( ) ) ) ?
432- . as_array ( ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyIncorrectType" , property = "result" , property_type = "array" ) . to_string ( ) ) ) ?[ 0 ]
433- . as_object ( ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyIncorrectType" , property = "result" , property_type = "object" ) . to_string ( ) ) ) ?
434- . get ( "properties" ) . ok_or ( DscError :: Operation ( t ! ( "dscresources.dscresource.propertyNotFound" , property = "properties" ) . to_string ( ) ) ) ?. clone ( ) ;
435- let diff_properties = get_diff ( & desired_state, & actual_state) ;
436- desired_state = redact ( & desired_state) ;
437- let test_result = TestResult :: Resource ( ResourceTestResponse {
438- desired_state,
439- actual_state,
440- in_desired_state : resource_result. in_desired_state ,
441- diff_properties,
442- } ) ;
443- return Ok ( test_result) ;
418+ return self . invoke_test_with_adapter ( adapter, & self . type_name , expected) ;
444419 }
445420
446421 match & self . implemented_as {
@@ -620,30 +595,16 @@ pub fn redact(value: &Value) -> Value {
620595///
621596/// # Errors
622597/// * `DscError` - The adapter manifest is not found or invalid
623- /// Retrieve the kind of adapter
624- ///
625- /// # Arguments
626- ///
627- /// * `adapter` - The adapter resource
628- ///
629- /// # Returns
630- ///
631- /// The input kind of the adapter
632- ///
633- /// # Errors
634- ///
635- /// * `DscError` - The adapter does not have a manifest or the manifest is invalid
636598pub fn get_adapter_input_kind ( adapter : & DscResource ) -> Result < AdapterInputKind , DscError > {
637- if let Some ( manifest) = & adapter. manifest {
638- if let Ok ( manifest) = serde_json:: from_value :: < ResourceManifest > ( manifest. clone ( ) ) {
639- if let Some ( adapter_operation) = manifest. adapter {
640- return Ok ( adapter_operation. input_kind ) ;
641- }
599+ if let Some ( manifest) = & adapter. manifest {
600+ if let Ok ( manifest) = serde_json:: from_value :: < ResourceManifest > ( manifest. clone ( ) ) {
601+ if let Some ( adapter_operation) = manifest. adapter {
602+ return Ok ( adapter_operation. input_kind ) ;
642603 }
643604 }
644- Err ( DscError :: Operation ( t ! ( "dscresources.dscresource.adapterManifestNotFound" , adapter = adapter. type_name) . to_string ( ) ) )
645605 }
646-
606+ Err ( DscError :: Operation ( t ! ( "dscresources.dscresource.adapterManifestNotFound" , adapter = adapter. type_name) . to_string ( ) ) )
607+ }
647608
648609#[ must_use]
649610/// Performs a comparison of two JSON Values if the expected is a strict subset of the actual
0 commit comments