Skip to content

Commit

Permalink
SNOW-723810: Fix Linux and Mac tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Sep 22, 2023
1 parent ac125f5 commit 1a91a40
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SFFileTransferAgentTest : SFBaseTest
[SetUp]
public void BeforeTest()
{
// Base object's names on on worker thread id
// Base object's names on worker thread id
var threadSuffix = TestContext.CurrentContext.WorkerId?.Replace('#', '_');

// Set values for thread variables
Expand Down Expand Up @@ -134,6 +134,12 @@ public void BeforeTest()
[TearDown]
public void AfterTest()
{
// Delete stage directory recursively
if (Directory.Exists(t_locationStage))
{
Directory.Delete(t_locationStage, true);
}

// Upload teardown
// Delete mock files
foreach (string location in _srcLocations)
Expand All @@ -142,7 +148,7 @@ public void AfterTest()
}

// Download teardown
// Delete stage/local directory recursively
// Delete local directory recursively
if (Directory.Exists(t_locationStage))
{
Directory.Delete(t_locationStage, true);
Expand Down Expand Up @@ -324,9 +330,9 @@ public void TestUploadWithWilcardInTheFilename()

// Write the mock files
int numberOfFiles = 3;
for (int i = 0; i < numberOfFiles; i++)
for (int index = 0; index < numberOfFiles; index++)
{
File.WriteAllText($"{mockFileName}{i}.{extension}", FileContent);
File.WriteAllText($"{mockFileName}{index}.{extension}", FileContent);
}

// Set command to upload
Expand All @@ -341,17 +347,17 @@ public void TestUploadWithWilcardInTheFilename()
SFBaseResultSet result = _fileTransferAgent.result();

// Assert
for (int i = 0; i < numberOfFiles; i++)
for (int index = 0; index < numberOfFiles; index++)
{
result.Next();

// Assert the file is uploaded
Assert.AreEqual(ResultStatus.UPLOADED.ToString(), GetResultValue(result, SFResultSet.PutGetResponseRowTypeInfo.ResultStatus));
// Check the name of the source file and destination file are the same
Assert.AreEqual($"{mockFileName}{i}.{extension}", GetResultValue(result, SFResultSet.PutGetResponseRowTypeInfo.SourceFileName));
Assert.AreEqual($"{mockFileName}{i}.{extension}", GetResultValue(result, SFResultSet.PutGetResponseRowTypeInfo.DestinationFileName));
Assert.IsTrue(GetResultValue(result, SFResultSet.PutGetResponseRowTypeInfo.SourceFileName).Contains(mockFileName));
Assert.IsTrue(GetResultValue(result, SFResultSet.PutGetResponseRowTypeInfo.DestinationFileName).Contains(mockFileName));

File.Delete($"{mockFileName}{i}.{extension}");
File.Delete($"{mockFileName}{index}.{extension}");
}
}

Expand Down

0 comments on commit 1a91a40

Please sign in to comment.