Преглед изворни кода

fix flaky SFTP file time tests (#1414)

* fix flaky SFTP file time tests

These asserts currently assume that DateTime.Now and the
creation timestamp on the server happen within the same second.

Note that I didn't change the asserts below where an explicit
timestamp is set. From my understanding, these should not be affected.

example: https://ci.appveyor.com/project/drieseng/ssh-net/builds/49850731/job/u6lk0cyipbxkp4jd

* remove asserts
mus65 пре 1 година
родитељ
комит
dda27a3177
1 измењених фајлова са 3 додато и 18 уклоњено
  1. 3 18
      test/Renci.SshNet.IntegrationTests/SftpTests.cs

+ 3 - 18
test/Renci.SshNet.IntegrationTests/SftpTests.cs

@@ -6142,20 +6142,15 @@ namespace Renci.SshNet.IntegrationTests
             client.Connect();
 
             using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(testContent));
-            var currentTime = DateTime.Now;
 
             client.UploadFile(fileStream, testFilePath);
 
             try
             {
-                var time = client.GetLastAccessTime(testFilePath);
-
-                DateTimeAssert.AreEqual(currentTime.TruncateToWholeSeconds(), time);
-
                 var newTime = new DateTime(1986, 03, 15, 01, 02, 03, 123, DateTimeKind.Local);
 
                 client.SetLastAccessTime(testFilePath, newTime);
-                time = client.GetLastAccessTime(testFilePath);
+                var time = client.GetLastAccessTime(testFilePath);
 
                 DateTimeAssert.AreEqual(newTime.TruncateToWholeSeconds(), time);
             }
@@ -6175,19 +6170,14 @@ namespace Renci.SshNet.IntegrationTests
             client.Connect();
 
             using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(testContent));
-            var currentTime = DateTime.UtcNow;
 
             client.UploadFile(fileStream, testFilePath);
             try
             {
-                var time = client.GetLastAccessTimeUtc(testFilePath);
-
-                DateTimeAssert.AreEqual(currentTime.TruncateToWholeSeconds(), time);
-
                 var newTime = new DateTime(1986, 03, 15, 01, 02, 03, 123, DateTimeKind.Utc);
 
                 client.SetLastAccessTimeUtc(testFilePath, newTime);
-                time = client.GetLastAccessTimeUtc(testFilePath);
+                var time = client.GetLastAccessTimeUtc(testFilePath);
 
                 DateTimeAssert.AreEqual(newTime.TruncateToWholeSeconds(), time);
             }
@@ -6206,19 +6196,14 @@ namespace Renci.SshNet.IntegrationTests
             client.Connect();
 
             using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(testContent));
-            var currentTime = DateTime.Now;
 
             client.UploadFile(fileStream, testFilePath);
             try
             {
-                var time = client.GetLastWriteTime(testFilePath);
-
-                DateTimeAssert.AreEqual(currentTime.TruncateToWholeSeconds(), time);
-
                 var newTime = new DateTime(1986, 03, 15, 01, 02, 03, 123, DateTimeKind.Local);
 
                 client.SetLastWriteTime(testFilePath, newTime);
-                time = client.GetLastWriteTime(testFilePath);
+                var time = client.GetLastWriteTime(testFilePath);
 
                 DateTimeAssert.AreEqual(newTime.TruncateToWholeSeconds(), time);
             }