Skip to content

Commit dda27a3

Browse files
authored
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
1 parent fdbc4d3 commit dda27a3

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

test/Renci.SshNet.IntegrationTests/SftpTests.cs

+3-18
Original file line numberDiff line numberDiff line change
@@ -6142,20 +6142,15 @@ public void Sftp_SetLastAccessTime()
61426142
client.Connect();
61436143

61446144
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(testContent));
6145-
var currentTime = DateTime.Now;
61466145

61476146
client.UploadFile(fileStream, testFilePath);
61486147

61496148
try
61506149
{
6151-
var time = client.GetLastAccessTime(testFilePath);
6152-
6153-
DateTimeAssert.AreEqual(currentTime.TruncateToWholeSeconds(), time);
6154-
61556150
var newTime = new DateTime(1986, 03, 15, 01, 02, 03, 123, DateTimeKind.Local);
61566151

61576152
client.SetLastAccessTime(testFilePath, newTime);
6158-
time = client.GetLastAccessTime(testFilePath);
6153+
var time = client.GetLastAccessTime(testFilePath);
61596154

61606155
DateTimeAssert.AreEqual(newTime.TruncateToWholeSeconds(), time);
61616156
}
@@ -6175,19 +6170,14 @@ public void Sftp_SetLastAccessTimeUtc()
61756170
client.Connect();
61766171

61776172
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(testContent));
6178-
var currentTime = DateTime.UtcNow;
61796173

61806174
client.UploadFile(fileStream, testFilePath);
61816175
try
61826176
{
6183-
var time = client.GetLastAccessTimeUtc(testFilePath);
6184-
6185-
DateTimeAssert.AreEqual(currentTime.TruncateToWholeSeconds(), time);
6186-
61876177
var newTime = new DateTime(1986, 03, 15, 01, 02, 03, 123, DateTimeKind.Utc);
61886178

61896179
client.SetLastAccessTimeUtc(testFilePath, newTime);
6190-
time = client.GetLastAccessTimeUtc(testFilePath);
6180+
var time = client.GetLastAccessTimeUtc(testFilePath);
61916181

61926182
DateTimeAssert.AreEqual(newTime.TruncateToWholeSeconds(), time);
61936183
}
@@ -6206,19 +6196,14 @@ public void Sftp_SetLastWriteTime()
62066196
client.Connect();
62076197

62086198
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(testContent));
6209-
var currentTime = DateTime.Now;
62106199

62116200
client.UploadFile(fileStream, testFilePath);
62126201
try
62136202
{
6214-
var time = client.GetLastWriteTime(testFilePath);
6215-
6216-
DateTimeAssert.AreEqual(currentTime.TruncateToWholeSeconds(), time);
6217-
62186203
var newTime = new DateTime(1986, 03, 15, 01, 02, 03, 123, DateTimeKind.Local);
62196204

62206205
client.SetLastWriteTime(testFilePath, newTime);
6221-
time = client.GetLastWriteTime(testFilePath);
6206+
var time = client.GetLastWriteTime(testFilePath);
62226207

62236208
DateTimeAssert.AreEqual(newTime.TruncateToWholeSeconds(), time);
62246209
}

0 commit comments

Comments
 (0)