11import test from "ava" ;
22import sinon from "sinon" ;
33
4+ import { RepositoryPropertyName } from "../feature-flags/properties" ;
45import { getTestActionsEnv , setupTests } from "../testing-utils" ;
56
67import { getConfigFileInput } from "./file" ;
@@ -9,10 +10,14 @@ setupTests(test);
910
1011test ( "getConfigFileInput returns undefined by default" , async ( t ) => {
1112 const actionsEnv = getTestActionsEnv ( ) ;
12- const result = getConfigFileInput ( actionsEnv ) ;
13+ const result = getConfigFileInput ( actionsEnv , { } ) ;
1314 t . is ( result , undefined ) ;
1415} ) ;
1516
17+ const repositoryProperties = {
18+ [ RepositoryPropertyName . CONFIG_FILE ] : "/path/from/property" ,
19+ } ;
20+
1621test ( "getConfigFileInput returns input value" , async ( t ) => {
1722 const actionsEnv = getTestActionsEnv ( ) ;
1823 const testInput = "/some/path" ;
@@ -21,6 +26,16 @@ test("getConfigFileInput returns input value", async (t) => {
2126 . withArgs ( "config-file" )
2227 . returns ( testInput ) ;
2328
24- const result = getConfigFileInput ( actionsEnv ) ;
29+ // Even though both an input and repository property are configured,
30+ // we prefer the direct input to the Action.
31+ const result = getConfigFileInput ( actionsEnv , repositoryProperties ) ;
2532 t . is ( result , testInput ) ;
2633} ) ;
34+
35+ test ( "getConfigFileInput returns repository property value" , async ( t ) => {
36+ const actionsEnv = getTestActionsEnv ( ) ;
37+
38+ // Since there is no direct input, we should use the repository property.
39+ const result = getConfigFileInput ( actionsEnv , repositoryProperties ) ;
40+ t . is ( result , repositoryProperties [ RepositoryPropertyName . CONFIG_FILE ] ) ;
41+ } ) ;
0 commit comments