mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-01-06 13:20:29 -06:00
next cloud unit test
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user