@@ -409,19 +409,19 @@ private async Task<int> RunAsync(RunnerSettings settings, bool runOnce = false)
409
409
autoUpdateInProgress = true ;
410
410
var runnerUpdateMessage = JsonUtility . FromString < AgentRefreshMessage > ( message . Body ) ;
411
411
// Can mock the update for testing
412
- if ( true || StringUtil . ConvertToBoolean ( Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE" ) ) )
412
+ if ( StringUtil . ConvertToBoolean ( Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE" ) ) )
413
413
{
414
414
415
- // the runnmock_update_messages .json file should be of format [{" targetVersion":"2.284.1"}, {"targetVersion":"2.285.0"}]
415
+ // the mock_update_messages .json file should be of format { "2.283.2": {" targetVersion":"2.284.1"}, "2.284.1": {"targetVersion":"2.285.0"}}
416
416
var mockUpdatesPath = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , "mock_update_messages.json" ) ;
417
417
if ( File . Exists ( mockUpdatesPath ) )
418
418
{
419
- var mockUpdateMessages = JsonUtility . FromString < List < AgentRefreshMessage > > ( File . ReadAllText ( mockUpdatesPath ) ) ;
420
- if ( mockUpdateMessages . Any ( ) )
419
+ var mockUpdateMessages = JsonUtility . FromString < Dictionary < string , AgentRefreshMessage > > ( File . ReadAllText ( mockUpdatesPath ) ) ;
420
+ if ( mockUpdateMessages . ContainsKey ( BuildConstants . RunnerPackage . Version ) )
421
421
{
422
- // Mock only the version
423
- _term . WriteLine ( $ "Mocking update, using version { mockUpdateMessages . First ( ) . TargetVersion } instead of { runnerUpdateMessage . TargetVersion } ") ;
424
- runnerUpdateMessage = new AgentRefreshMessage ( runnerUpdateMessage . AgentId , mockUpdateMessages . First ( ) . TargetVersion , runnerUpdateMessage . Timeout ) ;
422
+ var mockTargetVersion = mockUpdateMessages [ BuildConstants . RunnerPackage . Version ] . TargetVersion ;
423
+ _term . WriteLine ( $ "Mocking update, using version { mockTargetVersion } instead of { runnerUpdateMessage . TargetVersion } ") ;
424
+ runnerUpdateMessage = new AgentRefreshMessage ( runnerUpdateMessage . AgentId , mockTargetVersion , runnerUpdateMessage . Timeout ) ;
425
425
var temp = JsonUtility . ToString ( mockUpdateMessages . Skip ( 1 ) ) ;
426
426
File . WriteAllText ( mockUpdatesPath , JsonUtility . ToString ( mockUpdateMessages . Skip ( 1 ) ) ) ;
427
427
}
0 commit comments