@@ -506,6 +506,85 @@ public async Task Scenario5(string inputJson)
506506 }
507507 }
508508
509+
510+ /// <summary>
511+ /// 1. Restore from the initial tag in pull/scenarios
512+ /// 2. Only delete a file
513+ /// 3. Push to new branch
514+ /// 4. Verify local files are what is expected
515+ /// 5. Verify assets.json was updated with the new commit Tag
516+ /// </summary>
517+ /// <param name="inputJson"></param>
518+ /// <returns></returns>
519+ [ EnvironmentConditionalSkipTheory ]
520+ [ InlineData (
521+ @"{
522+ ""AssetsRepo"": ""Azure/azure-sdk-assets-integration"",
523+ ""AssetsRepoPrefixPath"": ""pull/scenarios"",
524+ ""AssetsRepoId"": """",
525+ ""TagPrefix"": ""language/tables"",
526+ ""Tag"": ""python/tables_fc54d0""
527+ }" ) ]
528+ [ Trait ( "Category" , "Integration" ) ]
529+ public async Task EnsureOnlyDeletesDetected ( string inputJson )
530+ {
531+ var folderStructure = new string [ ]
532+ {
533+ GitStoretests . AssetsJson
534+ } ;
535+
536+ Assets assets = JsonSerializer . Deserialize < Assets > ( inputJson ) ;
537+ Assets updatedAssets = null ;
538+ string originalTagPrefix = assets . TagPrefix ;
539+ string originalTag = assets . Tag ;
540+ var testFolder = TestHelpers . DescribeTestFolder ( assets , folderStructure , isPushTest : true ) ;
541+ try
542+ {
543+ // Ensure that the Tag was updated
544+ Assert . NotEqual ( originalTag , assets . TagPrefix ) ;
545+
546+ var jsonFileLocation = Path . Join ( testFolder , GitStoretests . AssetsJson ) ;
547+
548+ var parsedConfiguration = await _defaultStore . ParseConfigurationFile ( jsonFileLocation ) ;
549+ await _defaultStore . Restore ( jsonFileLocation ) ;
550+
551+ // Calling Path.GetFullPath of the Path.Combine will ensure any directory separators are normalized for
552+ // the OS the test is running on. The reason being is that AssetsRepoPrefixPath, if there's a separator,
553+ // will be a forward one as expected by git but on Windows this won't result in a usable path.
554+ string localFilePath = Path . GetFullPath ( Path . Combine ( parsedConfiguration . AssetsRepoLocation . ToString ( ) , parsedConfiguration . AssetsRepoPrefixPath . ToString ( ) ) ) ;
555+
556+ // These are the files pulled down with the original Tag
557+ Assert . Equal ( 3 , System . IO . Directory . EnumerateFiles ( localFilePath ) . Count ( ) ) ;
558+ Assert . True ( TestHelpers . VerifyFileVersion ( localFilePath , "file1.txt" , 1 ) ) ;
559+ Assert . True ( TestHelpers . VerifyFileVersion ( localFilePath , "file2.txt" , 1 ) ) ;
560+ Assert . True ( TestHelpers . VerifyFileVersion ( localFilePath , "file3.txt" , 1 ) ) ;
561+
562+ File . Delete ( Path . Combine ( localFilePath , "file2.txt" ) ) ;
563+
564+ // Push the update, it should be a clean push
565+ await _defaultStore . Push ( jsonFileLocation ) ;
566+
567+ // Verify that after the push the directory still contains our updated files
568+ Assert . Equal ( 2 , System . IO . Directory . EnumerateFiles ( localFilePath ) . Count ( ) ) ;
569+ Assert . True ( TestHelpers . VerifyFileVersion ( localFilePath , "file1.txt" , 1 ) ) ;
570+ Assert . True ( TestHelpers . VerifyFileVersion ( localFilePath , "file3.txt" , 1 ) ) ;
571+
572+ // Ensure that the config was updated with the new Tag as part of the push
573+ updatedAssets = TestHelpers . LoadAssetsFromFile ( jsonFileLocation ) ;
574+ Assert . NotEqual ( originalTag , updatedAssets . Tag ) ;
575+
576+ // Ensure that the targeted tag is present on the repo
577+ TestHelpers . CheckExistenceOfTag ( updatedAssets , localFilePath ) ;
578+ await TestHelpers . CheckBreadcrumbAgainstAssetsJsons ( new string [ ] { jsonFileLocation } ) ;
579+ }
580+ finally
581+ {
582+ DirectoryHelper . DeleteGitDirectory ( testFolder ) ;
583+ TestHelpers . CleanupIntegrationTestTag ( assets ) ;
584+ TestHelpers . CleanupIntegrationTestTag ( updatedAssets ) ;
585+ }
586+ }
587+
509588 /// <summary>
510589 /// 1. Restore from a tag that has minimal existing files and a long destination path
511590 /// 2. Add a _bunch_ of files
0 commit comments