1
1
import { validateFixCommandIsSupported } from '../src/cli/commands/fix/validate-fix-command-is-supported' ;
2
+ import { CommandNotSupportedError } from '../src/lib/errors/command-not-supported' ;
3
+ import { FeatureNotSupportedByEcosystemError } from '../src/lib/errors/not-supported-by-ecosystem' ;
2
4
import * as featureFlags from '../src/lib/feature-flags' ;
3
5
import { ShowVulnPaths } from '../src/lib/types' ;
4
6
describe ( 'setDefaultTestOptions' , ( ) => {
@@ -19,7 +21,9 @@ describe('setDefaultTestOptions', () => {
19
21
. spyOn ( featureFlags , 'isFeatureFlagSupportedForOrg' )
20
22
. mockResolvedValue ( { ok : false } ) ;
21
23
const options = { path : '/' , showVulnPaths : 'all' as ShowVulnPaths } ;
22
- expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError ( '' ) ;
24
+ expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError (
25
+ new CommandNotSupportedError ( 'snyk fix' , undefined ) ,
26
+ ) ;
23
27
} ) ;
24
28
25
29
it ( 'fix is NOT supported for --source + enabled FF' , ( ) => {
@@ -31,7 +35,9 @@ describe('setDefaultTestOptions', () => {
31
35
showVulnPaths : 'all' as ShowVulnPaths ,
32
36
source : true ,
33
37
} ;
34
- expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError ( '' ) ;
38
+ expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError (
39
+ new FeatureNotSupportedByEcosystemError ( 'snyk fix' , 'cpp' ) ,
40
+ ) ;
35
41
} ) ;
36
42
37
43
it ( 'fix is NOT supported for --docker + enabled FF' , ( ) => {
@@ -43,7 +49,9 @@ describe('setDefaultTestOptions', () => {
43
49
showVulnPaths : 'all' as ShowVulnPaths ,
44
50
docker : true ,
45
51
} ;
46
- expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError ( '' ) ;
52
+ expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError (
53
+ new FeatureNotSupportedByEcosystemError ( 'snyk fix' , 'docker' ) ,
54
+ ) ;
47
55
} ) ;
48
56
49
57
it ( 'fix is NOT supported for --code + enabled FF' , ( ) => {
@@ -55,6 +63,8 @@ describe('setDefaultTestOptions', () => {
55
63
showVulnPaths : 'all' as ShowVulnPaths ,
56
64
code : true ,
57
65
} ;
58
- expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError ( '' ) ;
66
+ expect ( validateFixCommandIsSupported ( options ) ) . rejects . toThrowError (
67
+ new FeatureNotSupportedByEcosystemError ( 'snyk fix' , 'code' ) ,
68
+ ) ;
59
69
} ) ;
60
70
} ) ;
0 commit comments