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' {
66
66
$resource.capabilities | Should - Contain ' Get'
67
67
$resource.capabilities | Should - Contain ' Export'
68
68
}
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
+ }
69
75
}
Original file line number Diff line number Diff line change @@ -204,12 +204,14 @@ impl ResourceDiscovery for CommandDiscovery {
204
204
205
205
let mut adapted_resources = BTreeMap :: < String , Vec < DscResource > > :: new ( ) ;
206
206
207
+ let mut found_adapter: bool = false ;
207
208
for ( adapter_name, adapters) in & self . adapters {
208
209
for adapter in adapters {
209
210
if !regex. is_match ( adapter_name) {
210
211
continue ;
211
212
}
212
213
214
+ found_adapter = true ;
213
215
info ! ( "Enumerating resources for adapter '{}'" , adapter_name) ;
214
216
let pb_adapter_span = warn_span ! ( "" ) ;
215
217
pb_adapter_span. pb_set_style ( & ProgressStyle :: with_template (
@@ -272,6 +274,10 @@ impl ResourceDiscovery for CommandDiscovery {
272
274
}
273
275
}
274
276
277
+ if !found_adapter {
278
+ return Err ( DscError :: AdapterNotFound ( adapter_filter. to_string ( ) ) ) ;
279
+ }
280
+
275
281
self . adapted_resources = adapted_resources;
276
282
Ok ( ( ) )
277
283
}
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ use tree_sitter::LanguageError;
10
10
11
11
#[ derive( Error , Debug ) ]
12
12
pub enum DscError {
13
+ #[ error( "Adapter '{0}' not found" ) ]
14
+ AdapterNotFound ( String ) ,
15
+
13
16
#[ error( "Function boolean argument conversion error: {0}" ) ]
14
17
BooleanConversion ( #[ from] std:: str:: ParseBoolError ) ,
15
18
You can’t perform that action at this time.
0 commit comments