Skip to content

Commit

Permalink
Test for safe local file write
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Dec 12, 2022
1 parent e183068 commit 4003e6b
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Assets/UXF/Tests/Editor/TestFileIOManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,37 @@ public void FileSaverRelPath()
);
}

[Test]
public void MoveToBackup()
{
fileSaver.StoragePath = "test_output";
if (Directory.Exists(fileSaver.StoragePath))
{
Directory.Delete(fileSaver.StoragePath, true);
}

fileSaver.SetUp();

string fileName = "testMoveToBackup";
fileSaver.HandleText("", "a", "b", 1, fileName, UXFDataType.TrialResults);
fileSaver.HandleText("", "a", "b", 1, fileName, UXFDataType.TrialResults);
fileSaver.HandleText("", "a", "b", 1, fileName, UXFDataType.TrialResults);

bool done = false;
// Wait for the workers to finish
fileSaver.ManageInWorker(() => done = true);

while (!done) { System.Threading.Thread.Sleep(50); }

string testFilesDirectory = fileSaver.GetSessionPath("a", "b", 1);

string[] files = Directory.GetFiles(testFilesDirectory, $"{fileName}*.txt");
Assert.AreEqual(files.Length, 3);

fileSaver.CleanUp();
Directory.Delete(fileSaver.StoragePath, true);
}

}

}
}

0 comments on commit 4003e6b

Please sign in to comment.