mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 12:37:48 +01:00
Fix tests
This commit is contained in:
@@ -11,7 +11,7 @@ public class RemoteObjectServiceClient {
|
||||
ObjectIndexService objectIndexService;
|
||||
|
||||
public Uni<Object> getObject(String namespace, String name) {
|
||||
return Uni.createFrom().item(null);
|
||||
return Uni.createFrom().item(() -> null);
|
||||
}
|
||||
|
||||
public Uni<Boolean> notifyUpdate(String namespace, String name) {
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
package com.usatiuk.dhfs.storage;
|
||||
package com.usatiuk.dhfs;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.runtime.ShutdownEvent;
|
||||
import io.quarkus.runtime.StartupEvent;
|
||||
import jakarta.annotation.Priority;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.enterprise.event.Observes;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
@QuarkusTest
|
||||
public abstract class SimpleFileRepoTest {
|
||||
@ApplicationScoped
|
||||
public class TestDataCleaner {
|
||||
@ConfigProperty(name = "dhfs.objects.persistence.files.root")
|
||||
String tempDirectory;
|
||||
@ConfigProperty(name = "dhfs.objects.distributed.root")
|
||||
String tempDirectoryIdx;
|
||||
|
||||
void init(@Observes @Priority(1) StartupEvent event) throws IOException {
|
||||
purgeDirectory(Path.of(tempDirectory).toFile());
|
||||
purgeDirectory(Path.of(tempDirectoryIdx).toFile());
|
||||
}
|
||||
|
||||
void shutdown(@Observes @Priority(1000000000) ShutdownEvent event) throws IOException {
|
||||
purgeDirectory(Path.of(tempDirectory).toFile());
|
||||
purgeDirectory(Path.of(tempDirectoryIdx).toFile());
|
||||
}
|
||||
|
||||
void purgeDirectory(File dir) {
|
||||
for (File file : Objects.requireNonNull(dir.listFiles())) {
|
||||
if (file.isDirectory())
|
||||
@@ -22,10 +36,4 @@ public abstract class SimpleFileRepoTest {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void teardown() {
|
||||
purgeDirectory(Path.of(tempDirectory).toFile());
|
||||
purgeDirectory(Path.of(tempDirectoryIdx).toFile());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.usatiuk.dhfs.files;
|
||||
|
||||
import com.usatiuk.dhfs.storage.SimpleFileRepoTest;
|
||||
import com.usatiuk.dhfs.storage.files.objects.Chunk;
|
||||
import com.usatiuk.dhfs.storage.files.objects.File;
|
||||
import com.usatiuk.dhfs.storage.files.service.DhfsFileService;
|
||||
@@ -23,7 +22,7 @@ class Profiles {
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(Profiles.DhfsFileServiceSimpleTestProfile.class)
|
||||
public class DhfsFileServiceSimpleTest extends SimpleFileRepoTest {
|
||||
public class DhfsFileServiceSimpleTest {
|
||||
@Inject
|
||||
DhfsFileService fileService;
|
||||
@Inject
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.usatiuk.dhfs.fuse;
|
||||
|
||||
import com.usatiuk.dhfs.storage.SimpleFileRepoTest;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
@@ -19,7 +18,7 @@ class Profiles {
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(Profiles.DhfsFuseTestProfile.class)
|
||||
public class DhfsFuseTest extends SimpleFileRepoTest {
|
||||
public class DhfsFuseTest {
|
||||
@ConfigProperty(name = "dhfs.fuse.root")
|
||||
String root;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
class Profiles {
|
||||
public static class DhfsObjectGrpcServiceTestProfile implements QuarkusTestProfile {
|
||||
@@ -19,7 +18,7 @@ class Profiles {
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(Profiles.DhfsObjectGrpcServiceTestProfile.class)
|
||||
class DhfsObjectGrpcServiceTest extends SimpleFileRepoTest {
|
||||
class DhfsObjectGrpcServiceTest {
|
||||
@GrpcClient
|
||||
DhfsObjectGrpc dhfsObjectGrpc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user