File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -66,4 +66,10 @@ Describe 'Tests for listing resources' {
6666 $resource.capabilities | Should - Contain ' Get'
6767 $resource.capabilities | Should - Contain ' Export'
6868 }
69+
70+ It ' Invalid adapter returns an error' {
71+ $out = dsc resource list -- adapter ' foo*' 2>&1 | Out-String
72+ $LASTEXITCODE | Should - Be 0
73+ $out | Should - BeLike " *ERROR*Adapter 'foo`*' not found*"
74+ }
6975}
Original file line number Diff line number Diff line change @@ -204,12 +204,14 @@ impl ResourceDiscovery for CommandDiscovery {
204204
205205 let mut adapted_resources = BTreeMap :: < String , Vec < DscResource > > :: new ( ) ;
206206
207+ let mut found_adapter: bool = false ;
207208 for ( adapter_name, adapters) in & self . adapters {
208209 for adapter in adapters {
209210 if !regex. is_match ( adapter_name) {
210211 continue ;
211212 }
212213
214+ found_adapter = true ;
213215 info ! ( "Enumerating resources for adapter '{}'" , adapter_name) ;
214216 let pb_adapter_span = warn_span ! ( "" ) ;
215217 pb_adapter_span. pb_set_style ( & ProgressStyle :: with_template (
@@ -272,6 +274,10 @@ impl ResourceDiscovery for CommandDiscovery {
272274 }
273275 }
274276
277+ if !found_adapter {
278+ return Err ( DscError :: AdapterNotFound ( adapter_filter. to_string ( ) ) ) ;
279+ }
280+
275281 self . adapted_resources = adapted_resources;
276282 Ok ( ( ) )
277283 }
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ use tree_sitter::LanguageError;
1010
1111#[ derive( Error , Debug ) ]
1212pub enum DscError {
13+ #[ error( "Adapter '{0}' not found" ) ]
14+ AdapterNotFound ( String ) ,
15+
1316 #[ error( "Function boolean argument conversion error: {0}" ) ]
1417 BooleanConversion ( #[ from] std:: str:: ParseBoolError ) ,
1518
You can’t perform that action at this time.
0 commit comments