11import test from "ava" ;
22
33import { BundlePlatform } from "./bundle-platform" ;
4- import { ActionsEnvVars , Env } from "./environment" ;
4+ import { ActionsEnvVars } from "./environment" ;
55import { Feature } from "./feature-flags" ;
66import { BuiltInLanguage } from "./languages" ;
77import {
@@ -30,16 +30,16 @@ const ELIGIBLE_OPTIONS: PerLanguageBundleOptions = {
3030
3131async function checkEligibility (
3232 overrides : Partial < PerLanguageBundleOptions > ,
33- enabledFeatures : Feature [ ] = [ Feature . PerLanguageBundles ] ,
34- env : Env = getTestEnv ( {
35- [ ActionsEnvVars . RUNNER_ENVIRONMENT ] : "github-hosted" ,
36- } ) ,
33+ stateOverrides : Partial < ReturnType < typeof initAllState > > = { } ,
3734) {
3835 return getPerLanguageBundleLanguage (
3936 initAllState ( {
40- env,
41- features : createFeatures ( enabledFeatures ) ,
37+ env : getTestEnv ( {
38+ [ ActionsEnvVars . RUNNER_ENVIRONMENT ] : "github-hosted" ,
39+ } ) ,
40+ features : createFeatures ( [ Feature . PerLanguageBundles ] ) ,
4241 logger : getRecordingLogger ( [ ] , { logToConsole : false } ) ,
42+ ...stateOverrides ,
4343 } ) ,
4444 { ...ELIGIBLE_OPTIONS , ...overrides } ,
4545 ) ;
@@ -100,8 +100,9 @@ test("getPerLanguageBundleLanguage requires a GitHub-hosted runner", async (t) =
100100 t . is (
101101 await checkEligibility (
102102 { } ,
103- [ Feature . PerLanguageBundles ] ,
104- getTestEnv ( { [ ActionsEnvVars . RUNNER_ENVIRONMENT ] : "self-hosted" } ) ,
103+ {
104+ env : getTestEnv ( { [ ActionsEnvVars . RUNNER_ENVIRONMENT ] : "self-hosted" } ) ,
105+ } ,
105106 ) ,
106107 undefined ,
107108 ) ;
@@ -111,8 +112,9 @@ test("getPerLanguageBundleLanguage requires a GitHub-hosted runner", async (t) =
111112 t . is (
112113 await checkEligibility (
113114 { } ,
114- [ Feature . PerLanguageBundles ] ,
115- getTestEnv ( { RUNNER_TOOL_CACHE : "/opt/hostedtoolcache" } ) ,
115+ {
116+ env : getTestEnv ( { RUNNER_TOOL_CACHE : "/opt/hostedtoolcache" } ) ,
117+ } ,
116118 ) ,
117119 undefined ,
118120 ) ;
@@ -125,7 +127,7 @@ test("getPerLanguageBundleLanguage requires a supported release version", async
125127} ) ;
126128
127129test ( "getPerLanguageBundleLanguage requires the feature flag" , async ( t ) => {
128- t . is ( await checkEligibility ( { } , [ ] ) , undefined ) ;
130+ t . is ( await checkEligibility ( { } , { features : createFeatures ( [ ] ) } ) , undefined ) ;
129131} ) ;
130132
131133test ( "getPerLanguageBundleLanguage explains a disabled feature before checking eligibility" , async ( t ) => {
@@ -162,13 +164,14 @@ test("getPerLanguageBundleLanguage skips only the release version check for the
162164 ] ) {
163165 t . is ( await checkEligibility ( { ...nightly , ...overrides } ) , undefined ) ;
164166 }
165- t . is ( await checkEligibility ( nightly , [ ] ) , undefined ) ;
166167 t . is (
167- await checkEligibility (
168- nightly ,
169- [ Feature . PerLanguageBundles ] ,
170- getTestEnv ( { [ ActionsEnvVars . RUNNER_ENVIRONMENT ] : "self-hosted" } ) ,
171- ) ,
168+ await checkEligibility ( nightly , { features : createFeatures ( [ ] ) } ) ,
169+ undefined ,
170+ ) ;
171+ t . is (
172+ await checkEligibility ( nightly , {
173+ env : getTestEnv ( { [ ActionsEnvVars . RUNNER_ENVIRONMENT ] : "self-hosted" } ) ,
174+ } ) ,
172175 undefined ,
173176 ) ;
174177} ) ;
0 commit comments