Skip to content

Commit

Permalink
Add missing tests, and TODOs for later follow-up
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed May 28, 2024
1 parent 1ce4397 commit aeac133
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public String getFilename() {

@JsProperty
public String getBasename() {
// TODO (deephaven-core#5068) remove extra check
if (parentPath.equals("/")) {
return path.substring(1);
}
return path.substring(parentPath.length() + 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public void testStorageService() {
return storageService.listItems("", null).then(items -> {
assertEquals(items.toString_(), 2, items.length);

// TODO (deephaven-core#5068) remove leading slash
Set<String> expected = new HashSet<>(Arrays.asList("layouts", "notebooks"));
for (int i = 0; i < items.length; i++) {
expected.remove(items.getAt(i).getFilename());
expected.remove(items.getAt(i).getBasename());
}
assertTrue(expected.toString(), expected.isEmpty());

Expand All @@ -48,38 +49,86 @@ public void testStorageService() {

return null;
}), storageService.listItems("/notebooks", null).then(items -> {
delayTestFinish(20_003);
delayTestFinish(20_004);

assertEquals(1, items.length);

assertEquals(JsItemType.DIRECTORY, items.getAt(0).getType());
assertEquals("myDir", items.getAt(0).getBasename());
return null;
}), storageService.listItems("notebooks/", null).then(items -> {
delayTestFinish(20_003);
delayTestFinish(20_005);

assertEquals(1, items.length);

assertEquals(JsItemType.DIRECTORY, items.getAt(0).getType());
assertEquals("myDir", items.getAt(0).getBasename());
return null;
}), storageService.listItems("/notebooks/", null).then(items -> {
delayTestFinish(20_003);
delayTestFinish(20_006);

assertEquals(1, items.length);

assertEquals(JsItemType.DIRECTORY, items.getAt(0).getType());
assertEquals("myDir", items.getAt(0).getBasename());
return null;
}));
}).then(ignore -> {
delayTestFinish(20_003);



finishTest();
return null;
}).catch_(this::report);
}).then(ignore -> storageService
.saveFile("layouts/myFile.txt", JsFileContents.text("hello, ", "world"), false)
.then(file -> {
delayTestFinish(20_007);

assertEquals("8ebc5e3a62ac2f344d41429607bcdc4c", file.getEtag());
return Promise.all(storageService.listItems("layouts", null)
.then(items -> {
delayTestFinish(20_008);

assertEquals(JsItemType.FILE, items.getAt(0).getType());
assertEquals("myFile.txt", items.getAt(0).getBasename());
return null;
}), storageService.loadFile("layouts/myFile.txt", null).then(contents -> {
delayTestFinish(20_009);

return contents.text().then(c -> {
delayTestFinish(20_010);

assertEquals("hello, world", c);
return null;
});
}), storageService.loadFile("/layouts/myFile.txt", null).then(contents -> {
delayTestFinish(20_011);

return contents.text().then(c -> {
delayTestFinish(20_012);

assertEquals("hello, world", c);
return null;
});
}), storageService.loadFile("layouts/myFile.txt", "8ebc5e3a62ac2f344d41429607bcdc4c").then(contents -> {
delayTestFinish(20_013);

return contents.text().then(c -> {
fail("should not have resolved");
return null;
}, error -> {
assertTrue(error.toString()
.contains("No contents available, please use provided etag"));
return null;
});
}), storageService.loadFile("layouts/myFile.txt", "definitely-the-wrong-hash").then(contents -> {
delayTestFinish(20_014);

return contents.text().then(c -> {
delayTestFinish(20_015);

assertEquals("hello, world", c);
return null;
});
}));
})).then(ignore -> {
finishTest();
return null;
}).catch_(this::report);
});
}

Expand Down

0 comments on commit aeac133

Please sign in to comment.