diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c079d46..235d99e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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/setup-msbuild@v1.1 + - uses: darenm/Setup-VSTest@v1.2 + - 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 diff --git a/Tests/FileUtilsTests.cs b/Tests/FileUtilsTests.cs index 5c04fdb..3d63063 100644 --- a/Tests/FileUtilsTests.cs +++ b/Tests/FileUtilsTests.cs @@ -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() { @@ -104,6 +111,7 @@ public void ChecksumTest() } } + /* [Test] [TestCase("EmbeddedResourceFile.txt")] [TestCase(null)] @@ -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 listFtpFiles = FileUtils.FtpList( - "ftp://localhost:21/", - "/", - "", - "", + FTP_HOST, + FTP_PATH, + FTP_USERNAME, + FTP_PASSWORD, false ); @@ -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 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) @@ -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 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) { @@ -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!"); @@ -285,5 +295,5 @@ public void FixAclTest(string identityUPN) - + } \ No newline at end of file