Skip to content

Commit

Permalink
Refactor file paths for cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Dec 2, 2024
1 parent e8938fe commit c6cbfc6
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions Snowflake.Data.Tests/UnitTests/SFFileTransferAgentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class SFFileTransferAgentTest : SFBaseTest
const string FileContent = "FTAFileContent";

// Mock file paths
const string FilePathWithoutSpaces = "C:/Users/Test/folder_without_space/*.*";
const string FilePathWithSpaces = "C:/Users/Test/folder with space/*.*";
static readonly string s_filePathWithoutSpaces = Path.Combine("C:\\Users\\Test\\", "folder_without_space", "*.*");
static readonly string s_filePathWithSpaces = Path.Combine("C:\\Users\\Test\\", "folder with space", "*.*");

[SetUp]
public void BeforeEachTest()
Expand Down Expand Up @@ -640,10 +640,29 @@ public void TestDownloadThrowsErrorDirectoryNotFound()
}

[Test]
[TestCase("PUT file://" + FilePathWithoutSpaces + " @TestStage", FilePathWithoutSpaces)]
[TestCase("PUT file://" + FilePathWithSpaces + " @TestStage", FilePathWithSpaces)]
[TestCase("PUT 'file://" + FilePathWithoutSpaces + "' @TestStage", FilePathWithoutSpaces)]
[TestCase("PUT 'file://" + FilePathWithSpaces + "' @TestStage", FilePathWithSpaces)]
public void TestGetFilePathWithoutSpacesFromPutCommand()
{
TestGetFilePathFromPutCommand("PUT file://" + s_filePathWithoutSpaces + " @TestStage", s_filePathWithoutSpaces);
}

[Test]
public void TestGetFilePathWithSpacesFromPutCommand()
{
TestGetFilePathFromPutCommand("PUT file://" + s_filePathWithSpaces + " @TestStage", s_filePathWithSpaces);
}

[Test]
public void TestGetFilePathWithoutSpacesAndWithSingleQuotesFromPutCommand()
{
TestGetFilePathFromPutCommand("PUT 'file://" + s_filePathWithoutSpaces + "' @TestStage", s_filePathWithoutSpaces);
}

[Test]
public void TestGetFilePathWithSpacesAndWithSingleQuotesFromPutCommand()
{
TestGetFilePathFromPutCommand("PUT 'file://" + s_filePathWithSpaces + "' @TestStage", s_filePathWithSpaces);
}

public void TestGetFilePathFromPutCommand(string query, string expectedFilePath)
{
var actualFilePath = SFFileTransferAgent.getFilePathFromPutCommand(query);
Expand Down

0 comments on commit c6cbfc6

Please sign in to comment.