Skip to content

Commit 843ce07

Browse files
committed
Improving test coverage for FileWorkspaceMap
1 parent f7157bb commit 843ce07

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/picoded/dstack/core/Core_FileWorkspaceMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ protected Set<String> backend_filterPathSet(final Set<String> rawSet, final Stri
554554

555555
// Normalize the folder path
556556
String searchPath = folderPath;
557-
if (searchPath.equals("/")) {
557+
if (searchPath == null || searchPath.equals("/")) {
558558
searchPath = "";
559559
}
560560
int searchPathLen = searchPath.length();

src/main/java/picoded/dstack/mongodb/MongoDB_FileWorkspaceMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ public Set<String> backend_getFileAndFolderPathSet(final String oid, String fold
828828
// Lets build the query for the "root file"
829829
Bson query = null;
830830

831-
// The fulle prefix path
831+
// The fuller prefix path
832832
String fullPrefixPath = oid + "/";
833833

834834
if (folderPath == null || folderPath.equals("/") || folderPath.isEmpty()) {

src/test/java/picoded/dstack/struct/simple/StructSimple_FileWorkspaceMap_test.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,12 @@ public void getPathSetLookup() {
348348
fileWorkspace.writeString("test/d1/file.txt", "anything");
349349
fileWorkspace.writeString("test/d2/file.txt", "anything");
350350

351-
// List files and folders
351+
// List all files and folders
352+
assertEquals(4, fileWorkspace.getFileAndFolderPathSet(null).size());
353+
assertEquals(4, fileWorkspace.getFileAndFolderPathSet("").size());
354+
assertEquals(4, fileWorkspace.getFileAndFolderPathSet("/").size());
355+
356+
// List files in sub folders
352357
assertEquals(4, fileWorkspace.getFileAndFolderPathSet("test").size());
353358
assertEquals(2, fileWorkspace.getFilePathSet("test").size());
354359
assertEquals(2, fileWorkspace.getFolderPathSet("test").size());

0 commit comments

Comments
 (0)