(minor) Fix test and improve error message

This commit is contained in:
Viktor Lofgren 2024-01-31 11:53:41 +01:00
parent 52a0255814
commit 98f3382cea
2 changed files with 7 additions and 0 deletions

View File

@ -230,6 +230,9 @@ public class FileStorageService {
{ {
var base = getStorageBase(FileStorageBaseType.forFileStorageType(type)); var base = getStorageBase(FileStorageBaseType.forFileStorageType(type));
if (null == base)
throw new IllegalStateException("No storage base for type " + type + " on node " + node);
Path newDir = allocateDirectory(base.asPath(), prefix); Path newDir = allocateDirectory(base.asPath(), prefix);
String relDir = base.asPath().relativize(newDir).normalize().toString(); String relDir = base.asPath().relativize(newDir).normalize().toString();

View File

@ -118,6 +118,10 @@ public class FileStorageServiceTest {
public void testAllocateTemp() throws IOException, SQLException { public void testAllocateTemp() throws IOException, SQLException {
String name = "test-" + UUID.randomUUID(); String name = "test-" + UUID.randomUUID();
// ensure a base exists
var base = fileStorageService.createStorageBase(name, createTempDir(), FileStorageBaseType.STORAGE);
tempDirs.add(base.asPath());
var storage = new FileStorageService(dataSource, 0); var storage = new FileStorageService(dataSource, 0);
var fileStorage = storage.allocateStorage(FileStorageType.CRAWL_DATA, "xyz", "thisShouldSucceed"); var fileStorage = storage.allocateStorage(FileStorageType.CRAWL_DATA, "xyz", "thisShouldSucceed");