Skip to content

Commit

Permalink
added test to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
acattaneo-bitagora committed Mar 7, 2023
1 parent 934646f commit af9a87f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 35 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
msbuild.exe ACUtils.sln /p:Configuration="Release" /p:Platform="Any CPU" /t:"Restore"
msbuild.exe ACUtils.sln /p:Configuration="Release" /p:Platform="Any CPU" /t:"Rebuild"
- uses: actions/cache@v3
id: cache-tests-build
env:
cache-name: cache-tests-build
with:
path: ./Tests/bin/Release
key: tests-${{ github.sha }}

#- name: Commit deploy
# run: |
# git config user.name github-actions
Expand All @@ -64,10 +72,30 @@ jobs:
# dist/*.nupkg
# dist/*.snupkg

publish:
test:
needs: build
runs-on: windows-2019
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- uses: microsoft/[email protected]
- uses: darenm/[email protected]
- uses: actions/cache@v3
id: cache-tests-build
env:
cache-name: cache-tests-build
with:
path: ./Tests/bin/Release
key: tests-${{ github.sha }}
- name: run test
run: |
[System.Environment]::SetEnvironmentVariable('ACUTILS_TEST_CONNECTION_STRING', '${{ secrets.ACUTILS_TEST_CONNECTION_STRING }}')
vstest.console.exe /Platform:x64 ./Tests/bin/Release/Tests.dll
publish:
needs: test
runs-on: windows-2019
if: github.ref == 'refs/heads/master'
steps:
- name: Setup NuGet
uses: nuget/setup-nuget@v1
Expand Down
78 changes: 44 additions & 34 deletions Tests/FileUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ namespace Tests
[TestFixture]
public class FileUtilsTests
{
/*
string FTP_USERNAME = System.Environment.GetEnvironmentVariable("FTP_USERNAME") ?? "test";
string FTP_PASSWORD = System.Environment.GetEnvironmentVariable("FTP_PASSWORD") ?? "test";
string FTP_PATH = System.Environment.GetEnvironmentVariable("FTP_PATH") ?? "/home/test";
string FTP_HOST = System.Environment.GetEnvironmentVariable("FTP_HOST") ?? "ftp://localhost:21/";
*/

[SetUp]
public void Setup()
{
Expand Down Expand Up @@ -104,6 +111,7 @@ public void ChecksumTest()
}
}

/*
[Test]
[TestCase("EmbeddedResourceFile.txt")]
[TestCase(null)]
Expand All @@ -115,18 +123,18 @@ public void FtpUpload(string ftpFile)
}
FileUtils.FtpUpload(
ftpFile,
"ftp://localhost:21/",
"/",
"",
"",
FTP_HOST,
FTP_PATH,
FTP_USERNAME,
FTP_PASSWORD,
false
);
System.Collections.Generic.List<string> listFtpFiles = FileUtils.FtpList(
"ftp://localhost:21/",
"/",
"",
"",
FTP_HOST,
FTP_PATH,
FTP_USERNAME,
FTP_PASSWORD,
false
);
Expand All @@ -151,20 +159,21 @@ public void FtpDownload(string filePath)
{
FileUtils.FtpDownload(
download_path.Value,
"ftp://localhost:21/",
System.IO.Path.GetFileName(filePath),
"",
"",
FTP_HOST,
$"{FTP_PATH}/{System.IO.Path.GetFileName(filePath)}",
FTP_USERNAME,
FTP_PASSWORD,
false
);
Assert.IsTrue(FileUtils.IsFile(download_path.Value));
System.Collections.Generic.List<string> list = FileUtils.FtpList(
"ftp://localhost:21/",
"/",
"",
"",
false);
FTP_HOST,
FTP_PATH,
FTP_USERNAME,
FTP_PASSWORD,
false
);
Assert.AreEqual(
expected: FileUtils.FileChecksum(filePath),
actual: FileUtils.FileChecksum(download_path.Value)
Expand All @@ -178,45 +187,46 @@ public void FtpFtpDelete()
{
Assert.IsFalse(
FileUtils.FtpDelete(
"ftp://localhost:21/",
FTP_HOST,
"file_not_found.txt",
"",
"",
FTP_USERNAME,
FTP_PASSWORD,
false
)
);
System.Collections.Generic.List<string> listFtpFiles = FileUtils.FtpList(
"ftp://localhost:21/",
"/",
"",
"",
FTP_HOST,
FTP_PATH,
FTP_USERNAME,
FTP_PASSWORD,
false
);
Assert.IsTrue(listFtpFiles.Count != 0);
foreach (string ftpFile in listFtpFiles)
{
Assert.IsTrue(
FileUtils.FtpDelete(
"ftp://localhost:21/",
FTP_HOST,
ftpFile,
"",
"",
FTP_USERNAME,
FTP_PASSWORD,
false
)
);
}
listFtpFiles = FileUtils.FtpList(
"ftp://localhost:21/",
"/",
"",
"",
FTP_HOST,
FTP_PATH,
FTP_USERNAME,
FTP_PASSWORD,
false
);
Assert.IsTrue(listFtpFiles.Count == 0);
}

*/

private bool _hasSomePermissions(string filePath, string accountName)
{
Expand Down Expand Up @@ -273,7 +283,7 @@ public void FixAclTest(string identityUPN)
// PROBLEMA: se si utilizza File.Move i permessi al file non vengono applicati
File.WriteAllText(sourcePath, "hello there!");
File.Move(sourcePath, destPath);
Assert.IsFalse(_hasSomePermissions( destPath, identityUPN));
Assert.IsFalse(_hasSomePermissions(destPath, identityUPN));

// ACUtils.FileUtils.MoveFile con parametro fixAcl=true risolve il problema XD
File.WriteAllText(sourcePath, "hello there!");
Expand All @@ -285,5 +295,5 @@ public void FixAclTest(string identityUPN)




}

0 comments on commit af9a87f

Please sign in to comment.