Skip to content

Commit 4e8776b

Browse files
committed
Test for safe local file write
1 parent e183068 commit 4e8776b

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

Assets/UXF/Tests/Editor/TestFileIOManager.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,33 @@ public void FileSaverRelPath()
148148
);
149149
}
150150

151+
[Test]
152+
public void MoveToBackup()
153+
{
154+
fileSaver.StoragePath = "test_output";
155+
if (Directory.Exists(fileSaver.StoragePath))
156+
{
157+
Directory.Delete(fileSaver.StoragePath, true);
158+
}
159+
160+
fileSaver.SetUp();
161+
162+
string fileName = "testMoveToBackup";
163+
fileSaver.HandleText("", "a", "b", 1, fileName, UXFDataType.TrialResults);
164+
fileSaver.HandleText("", "a", "b", 1, fileName, UXFDataType.TrialResults);
165+
fileSaver.HandleText("", "a", "b", 1, fileName, UXFDataType.TrialResults);
166+
167+
System.Threading.Thread.Sleep(500);
168+
169+
string testFilesDirectory = fileSaver.GetSessionPath("a", "b", 1);
170+
171+
string[] files = Directory.GetFiles(testFilesDirectory, $"{fileName}*.txt");
172+
Assert.AreEqual(files.Length, 3);
173+
174+
fileSaver.CleanUp();
175+
Directory.Delete(fileSaver.StoragePath, true);
176+
}
177+
151178
}
152179

153-
}
180+
}

0 commit comments

Comments
 (0)