added FF_TEMP_PATH for tests

This commit is contained in:
John Andrews
2024-08-31 16:28:34 +12:00
parent 1baeb195b3
commit c5103d3be6
5 changed files with 18 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ public class FileSizeCompareTests : TestBase
{
private string CreateFile(int size)
{
string tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".tmp");
string tempFile = Path.Combine(TempPath, Guid.NewGuid() + ".tmp");
System.IO.File.WriteAllText(tempFile, new string('a', size * 1000));
return tempFile;
}

View File

@@ -78,7 +78,7 @@ public class HasHardLinksTest : TestBase
[TestMethod]
public void HasHardLink()
{
testFile = Path.GetTempFileName();
testFile = Path.Combine(TempFile, Guid.NewGuid().ToString());
CreateHardLinkFile(testFile, 2);
var args = new FileFlows.Plugin.NodeParameters(testFile, Logger, false, string.Empty, MockFileService.Object);
@@ -92,7 +92,7 @@ public class HasHardLinksTest : TestBase
[TestMethod]
public void NoHardLinks()
{
testFile = Path.GetTempFileName();
testFile = Path.Combine(TempFile, Guid.NewGuid().ToString());
var args = new FileFlows.Plugin.NodeParameters(testFile, Logger, false, string.Empty, MockFileService.Object);
HasHardLinks element = new ();

View File

@@ -16,7 +16,7 @@ public class MoveTests : TestBase
public void MoveTests_Variable_Filename()
{
string fileName = Guid.NewGuid().ToString();
var tempFile = Path.Combine(Path.GetTempPath(),fileName+ ".mkv");
var tempFile = Path.Combine(TempPath,fileName+ ".mkv");
System.IO.File.WriteAllText(tempFile, "this is a temp file ");
var args = new NodeParameters(tempFile, Logger,
false, string.Empty, new LocalFileService());
@@ -31,7 +31,7 @@ public class MoveTests : TestBase
public void MoveTests_Variable_FilenameExt()
{
string fileName = Guid.NewGuid().ToString();
var tempFile = Path.Combine(Path.GetTempPath(),fileName+ ".mkv");
var tempFile = Path.Combine(TempPath,fileName+ ".mkv");
System.IO.File.WriteAllText(tempFile, "this is a temp file ");
var args = new NodeParameters(tempFile, Logger,
false, string.Empty, new LocalFileService());
@@ -46,14 +46,14 @@ public class MoveTests : TestBase
[TestMethod]
public void MoveTests_Variable_FilenameNoExtension()
{
var tempFileNoExtension = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
var tempFileNoExtension = Path.Combine(TempPath, Guid.NewGuid().ToString());
var tempFile = tempFileNoExtension + ".tmp";
System.IO.File.WriteAllText(tempFile, "this is a temp file");
var args = new NodeParameters(tempFile, Logger, false, string.Empty, new LocalFileService());
args.InitFile(tempFile);
// ensure we dont double up the extension after FF-154
string dest = MoveFile.GetDestinationPath(args, Path.GetTempPath(), "{file.NameNoExtension}");
string dest = MoveFile.GetDestinationPath(args, TempPath, "{file.NameNoExtension}");
Assert.AreEqual(tempFileNoExtension, dest);
}
@@ -62,7 +62,7 @@ public class MoveTests : TestBase
public void MoveTests_Variable_Ext()
{
string fileName = Guid.NewGuid().ToString();
var tempFile = Path.Combine(Path.GetTempPath(),fileName+ ".mkv");
var tempFile = Path.Combine(TempPath,fileName+ ".mkv");
System.IO.File.WriteAllText(tempFile, "this is a temp file ");
var args = new NodeParameters(tempFile, Logger,
false, string.Empty, new LocalFileService());
@@ -78,7 +78,7 @@ public class MoveTests : TestBase
public void MoveTests_Variable_Original_Filename()
{
string fileName = Guid.NewGuid().ToString();
var tempFile = Path.Combine(Path.GetTempPath(),fileName+ ".mkv");
var tempFile = Path.Combine(TempPath,fileName+ ".mkv");
System.IO.File.WriteAllText(tempFile, "this is a temp file ");
var args = new NodeParameters(tempFile, Logger,
false, string.Empty, new LocalFileService());
@@ -93,7 +93,7 @@ public class MoveTests : TestBase
public void MoveTests_Variable_Original_FilenameExt()
{
string fileName = Guid.NewGuid().ToString();
var tempFile = Path.Combine(Path.GetTempPath(),fileName+ ".mkv");
var tempFile = Path.Combine(TempPath,fileName+ ".mkv");
System.IO.File.WriteAllText(tempFile, "this is a temp file ");
var args = new NodeParameters(tempFile, Logger,
false, string.Empty, new LocalFileService());
@@ -107,7 +107,7 @@ public class MoveTests : TestBase
public void MoveTests_Variable_Original_NoExtension()
{
string fileName = Guid.NewGuid().ToString();
var tempFile = Path.Combine(Path.GetTempPath(),fileName+ ".mkv.mkv");
var tempFile = Path.Combine(TempPath,fileName+ ".mkv.mkv");
System.IO.File.WriteAllText(tempFile, "this is a temp file ");
var args = new NodeParameters(tempFile, Logger,
false, string.Empty, new LocalFileService());
@@ -137,10 +137,10 @@ public class MoveTests : TestBase
[TestMethod]
public void MoveTests_AdditionalFiles()
{
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
var tempDir = Path.Combine(TempPath, Guid.NewGuid().ToString());
Directory.CreateDirectory(tempDir);
var tempDir2 = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
var tempDir2 = Path.Combine(TempPath, Guid.NewGuid().ToString());
Directory.CreateDirectory(tempDir2);
var tempFilePrefix = Path.Combine(tempDir, Guid.NewGuid().ToString());

View File

@@ -62,7 +62,7 @@
//
// protected NodeParameters GetNodeParameters(string filename)
// {
// string tempPath = Path.GetTempPath();
// string tempPath = TempPath;
// string libPath = Path.Combine(tempPath, "media");
// if (Directory.Exists(libPath) == false)
// Directory.CreateDirectory(libPath);

View File

@@ -52,8 +52,10 @@ public abstract class TestBase
FileHelper.DontSetPermissions = true;
Logger.Writer = (msg) => TestContext.WriteLine(msg);
TempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString());
var tempPath = Environment.GetEnvironmentVariable("FF_TEMP_PATH");
if (string.IsNullOrWhiteSpace(tempPath))
tempPath = Path.GetTempPath();
TempPath = System.IO.Path.Combine(tempPath, Guid.NewGuid().ToString());
System.IO.Directory.CreateDirectory(TempPath);
TempFile = System.IO.Path.Combine(TempPath, Guid.NewGuid() + ".txt");
System.IO.File.WriteAllText(TempFile, Guid.NewGuid().ToString());