File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
test/Unit/DependencyManagement Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ internal static class DependencySnapshotFolderNameTools
2020
2121 public static string CreateUniqueName ( )
2222 {
23- var uniqueBase = DateTime . UtcNow . ToString ( "yyMMddHHmmssfff " ) ;
23+ var uniqueBase = DateTime . UtcNow . ToString ( "yyMMddHHmmssfffffff " ) ;
2424 return uniqueBase + InstalledPostfix ;
2525 }
2626
@@ -29,9 +29,9 @@ public static string CreateUniqueName()
2929 /// appending a postfix, so that that the resulting path follows a different
3030 /// pattern and can be discovered using a different file mask.
3131 /// For example, for the _installed_ path
32- /// ".../1907101234567 .r"
32+ /// ".../2107131600546921703 .r"
3333 /// the _installing_ path will be:
34- /// ".../1907101234567 .ri"
34+ /// ".../2107131600546921703 .ri"
3535 /// This makes it possible to enumerate all the installed snapshots by using ".../*.r" mask,
3636 /// and all the installing snapshots by using ".../*i" mask.
3737 /// </summary>
Original file line number Diff line number Diff line change @@ -10,14 +10,19 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Test.DependencyManagement
1010 using Xunit ;
1111
1212 using Microsoft . Azure . Functions . PowerShellWorker . DependencyManagement ;
13+ using System ;
1314
1415 public class DependencySnapshotFolderNameToolsTests
1516 {
1617 [ Fact ]
1718 public void CreatesUniqueEnoughNames ( )
1819 {
20+ // ticks = microseconds * (TimeSpan.TicksPerMillisecond / 1000)
21+ // A snapshot name created 1 microsecond (10 ticks) later must be different
22+ var waitTime = new TimeSpan ( 10 ) ;
23+
1924 var name1 = DependencySnapshotFolderNameTools . CreateUniqueName ( ) ;
20- Thread . Sleep ( 2 ) ; // A snapshot name created 2 milliseconds later must be different
25+ Thread . Sleep ( waitTime ) ;
2126 var name2 = DependencySnapshotFolderNameTools . CreateUniqueName ( ) ;
2227 Assert . NotEqual ( name1 , name2 ) ;
2328 }
@@ -40,8 +45,11 @@ public void NamesConvertedFromInstalledToInstallingDoNotHaveInstalledPostfix()
4045 [ Fact ]
4146 public void UniqueNamesConvertedFromInstalledToInstallingAreStillUnique ( )
4247 {
48+ // A snapshot name created 1 microsecond (10 ticks) later must be different
49+ var waitTime = new TimeSpan ( 10 ) ;
50+
4351 var name1 = DependencySnapshotFolderNameTools . CreateUniqueName ( ) ;
44- Thread . Sleep ( 2 ) ; // A snapshot name created 2 milliseconds later must be different
52+ Thread . Sleep ( waitTime ) ;
4553 var name2 = DependencySnapshotFolderNameTools . CreateUniqueName ( ) ;
4654
4755 var convertedToInstalling1 = DependencySnapshotFolderNameTools . ConvertInstalledToInstalling ( name1 ) ;
You can’t perform that action at this time.
0 commit comments