From 5471e84eb01fcb17a38de344ffaba52c8e2d0105 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Sun, 18 Aug 2019 13:39:46 -0700 Subject: [PATCH] Move download of test data to setup method. This allows one to more easily run the unit tests locally. --- .appveyor.yml | 2 +- .../UnitTest/CommandLineOperationsTests.cs | 15 ++++++++++++ build.sh | 23 ------------------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 3b2a549be..f030acd79 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,7 +28,7 @@ test_script: .\packages\OpenCover.4.6.166\tools\OpenCover.Console.exe ` -register:user ` -target:.\packages\NUnit.ConsoleRunner.3.4.0\tools\nunit3-console.exe ` - "-targetargs:""$elem"" /framework:net-4.5 /where:cat!=BulkData /result:""$testResultsFile""" ` + "-targetargs:""$elem"" /framework:net-4.5 /result:""$testResultsFile""" ` "-filter:+[Duplicati.Library.Main]* -[UnitTest]*" ` -output:opencover.xml ` -returntargetcode ` diff --git a/Duplicati/UnitTest/CommandLineOperationsTests.cs b/Duplicati/UnitTest/CommandLineOperationsTests.cs index de08e82b8..48bdd9435 100644 --- a/Duplicati/UnitTest/CommandLineOperationsTests.cs +++ b/Duplicati/UnitTest/CommandLineOperationsTests.cs @@ -19,6 +19,7 @@ using NUnit.Framework; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; namespace Duplicati.UnitTest { @@ -44,6 +45,20 @@ namespace Duplicati.UnitTest } } + public override void PrepareSourceData() + { + base.PrepareSourceData(); + + const string filename = "data.zip"; + string tempZipFile = Path.Combine(BASEFOLDER, filename); + using (WebClient client = new WebClient()) + { + client.DownloadFile($"https://s3.amazonaws.com/duplicati-test-file-hosting/{filename}", tempZipFile); + } + + System.IO.Compression.ZipFile.ExtractToDirectory(tempZipFile, BASEFOLDER); + } + [Test] [Category("BulkData")] [Category("BulkNormal")] diff --git a/build.sh b/build.sh index 6820729f1..ff550e4c9 100755 --- a/build.sh +++ b/build.sh @@ -32,32 +32,9 @@ msbuild /p:Configuration=Release Duplicati.sln cp -r ./Duplicati/Server/webroot ./Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/webroot echo "travis_fold:end:build_duplicati" -# download and extract testdata -echo "travis_fold:start:download_extract_testdata" -list_dir . - -if [ ! -d ~/tmp ]; then mkdir ~/tmp; fi -if [ ! -d ~/download ]; then mkdir ~/download; fi -if [ ! -d ~/download/bulk ]; then mkdir ~/download/bulk; fi - -if [ "$CATEGORY" == "BulkNormal" ] || [ "$CATEGORY" == "BulkNoSize" ]; then - # test if zip file exists and contains no errors - unzip -t ~/download/bulk/data.zip &> /dev/null || \ - wget --progress=dot:giga "https://s3.amazonaws.com/duplicati-test-file-hosting/data.zip" -O ~/download/bulk/data.zip - list_dir ~/download/bulk -fi - rm -rf ~/duplicati_testdata && mkdir ~/duplicati_testdata - -if [ "$CATEGORY" == "BulkNormal" ] || [ "$CATEGORY" == "BulkNoSize" ]; then - mkdir ~/duplicati_testdata/data - unzip -q ~/download/bulk/data.zip -d ~/duplicati_testdata/ - list_dir ~/duplicati_testdata/data -fi - chown -R $TESTUSER ~/duplicati_testdata/ chmod -R 755 ~/duplicati_testdata -echo "travis_fold:end:download_extract_testdata" # run unit tests echo "travis_fold:start:unit_test"