next cloud unit test

This commit is contained in:
John Andrews
2024-08-28 08:15:46 +12:00
parent 2a498acae0
commit 1fee7f08f5
3 changed files with 58 additions and 17 deletions

View File

@@ -1,7 +1,9 @@
#if(DEBUG)
using FileFlows.Nextcloud.FlowElements;
using FileFlows.Nextcloud.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using PluginTestLibrary;
namespace FileFlows.Nextcloud.Tests;
@@ -12,15 +14,19 @@ public class UploadTest : TestBase
[TestMethod]
public void Test()
{
var args = new NodeParameters("/home/john/src/ff-files/test-files/images/heic1.heic", Logger, false, string.Empty, new LocalFileService());
args.GetPluginSettingsJson = (string input) =>
{
return File.ReadAllText("../../../../../nextcloud.json");
};
var ele = new UploadToNextcloud();
ele.DestinationPath = "ff-test/" + Guid.NewGuid() + ".heic";
Assert.AreEqual(1, ele.Execute(args));
var args = GetNodeParameters(TempFile);
args.GetPluginSettingsJson = _ => """{"Username": "user", "Password": "password", "Url": "http://nextcloud.test" }""";
string destPath = "ff-test/" + Guid.NewGuid() + ".heic";
Mock<INextcloudUploader> mockUploader = new();
mockUploader.Setup(x => x.UploadFile(
It.Is<string>(y => y == TempFile),
It.Is<string>(y => y == destPath)))
.Returns(true);
var element = new UploadToNextcloud();
element.GetUploader = (_, _, _, _) => mockUploader.Object;
element.DestinationPath = destPath;
Assert.AreEqual(1, element.Execute(args));
}
}
#endif