@@ -2,6 +2,7 @@ import * as github from "@actions/github";
22import test from "ava" ;
33import sinon from "sinon" ;
44
5+ import { AnalysisKind } from "../analyses" ;
56import * as api from "../api-client" ;
67import { RegistryProxyVars } from "../environment" ;
78import { Feature } from "../feature-flags" ;
@@ -18,7 +19,7 @@ setupTests(test);
1819
1920test ( "getConfigFileInput returns undefined by default" , async ( t ) => {
2021 await callee ( getConfigFileInput )
21- . withArgs ( { } )
22+ . withArgs ( { } , undefined )
2223 . withFeatures ( [ Feature . ConfigFileRepositoryProperty ] )
2324 . passes ( t . is , undefined ) ;
2425} ) ;
@@ -40,7 +41,7 @@ test("getConfigFileInput returns input value", async (t) => {
4041 . withArgs ( "config-file" )
4142 . returns ( testInput ) ;
4243 } )
43- . withArgs ( repositoryProperties )
44+ . withArgs ( repositoryProperties , undefined )
4445 . logs ( t , "Using configuration file input from workflow" )
4546 . passes ( t . is , testInput ) ;
4647} ) ;
@@ -49,24 +50,52 @@ test("getConfigFileInput returns repository property value", async (t) => {
4950 // Since there is no direct input, we should use the repository property.
5051 await callee ( getConfigFileInput )
5152 . withFeatures ( [ Feature . ConfigFileRepositoryProperty ] )
52- . withArgs ( repositoryProperties )
53+ . withArgs ( repositoryProperties , undefined )
5354 . logs ( t , "Using configuration file input from repository property" )
5455 . passes ( t . is , repositoryProperties [ RepositoryPropertyName . CONFIG_FILE ] ) ;
5556} ) ;
5657
58+ test ( "getConfigFileInput returns repository property value for Code Scanning" , async ( t ) => {
59+ // Since there is no direct input, we should use the repository property.
60+ await callee ( getConfigFileInput )
61+ . withFeatures ( [ Feature . ConfigFileRepositoryProperty ] )
62+ . withArgs ( repositoryProperties , [ AnalysisKind . CodeScanning ] )
63+ . logs ( t , "Using configuration file input from repository property" )
64+ . passes ( t . is , repositoryProperties [ RepositoryPropertyName . CONFIG_FILE ] ) ;
65+ } ) ;
66+
67+ test ( "getConfigFileInput ignores repository property for other analysis kinds" , async ( t ) => {
68+ const unsupportedCases = [
69+ [ AnalysisKind . CodeQuality ] ,
70+ [ AnalysisKind . RiskAssessment ] ,
71+ [ AnalysisKind . CodeScanning , AnalysisKind . CodeQuality ] ,
72+ ] ;
73+
74+ const target = callee ( getConfigFileInput ) . withFeatures ( [
75+ Feature . ConfigFileRepositoryProperty ,
76+ ] ) ;
77+
78+ for ( const unsupportedCase of unsupportedCases ) {
79+ // Since the analysis kind is unsupported, we should ignore the repository property.
80+ await target
81+ . withArgs ( repositoryProperties , unsupportedCase )
82+ . passes ( t . is , undefined ) ;
83+ }
84+ } ) ;
85+
5786test ( "getConfigFileInput ignores empty repository property value" , async ( t ) => {
5887 // Since the repository property value is an empty/whitespace string, we should ignore it.
5988 await callee ( getConfigFileInput )
6089 . withFeatures ( [ Feature . ConfigFileRepositoryProperty ] )
61- . withArgs ( { [ RepositoryPropertyName . CONFIG_FILE ] : " " } )
90+ . withArgs ( { [ RepositoryPropertyName . CONFIG_FILE ] : " " } , undefined )
6291 . passes ( t . is , undefined ) ;
6392} ) ;
6493
6594test ( "getConfigFileInput ignores repository property value when FF is off" , async ( t ) => {
6695 // Since the FF is off, we should ignore the repository property value.
6796 await callee ( getConfigFileInput )
6897 . withFeatures ( [ ] )
69- . withArgs ( repositoryProperties )
98+ . withArgs ( repositoryProperties , undefined )
7099 . notLogs ( t , "Using configuration file input from repository property" )
71100 . logs (
72101 t ,
0 commit comments