MarginaliaSearch/code/processes/crawling-process/test/nu/marginalia/crawling/CrawlPlanLoaderTest.java
Viktor Lofgren 1d34224416 (refac) Remove src/main from all source code paths.
Look, this will make the git history look funny, but trimming unnecessary depth from the source tree is a very necessary sanity-preserving measure when dealing with a super-modularized codebase like this one.

While it makes the project configuration a bit less conventional, it will save you several clicks every time you jump between modules.  Which you'll do a lot, because it's *modul*ar.  The src/main/java convention makes a lot of sense for a non-modular project though.  This ain't that.
2024-02-23 16:13:40 +01:00

51 lines
1.4 KiB
Java

package nu.marginalia.crawling;
import plan.CrawlPlanLoader;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertEquals;
class CrawlPlanLoaderTest {
Path tempFile;
@BeforeEach
public void setUp() throws IOException {
tempFile = Files.createTempFile(getClass().getSimpleName(), ".yaml");
}
@AfterEach
public void tearDown() throws IOException {
Files.delete(tempFile);
}
@Test
void load() throws IOException {
Files.writeString(tempFile, """
jobSpec: "job.spec"
crawl:
dir: "/foo"
logName: "foo.log"
process:
dir: "/bar"
logName: "bar.log"
""");
var loader = new CrawlPlanLoader();
var ret = loader.load(tempFile);
assertEquals(Path.of("job.spec"), ret.getJobSpec());
assertEquals(Path.of("/foo"), ret.crawl.getDir());
assertEquals(Path.of("/foo/foo.log"), ret.crawl.getLogFile());
assertEquals(Path.of("/bar"), ret.process.getDir());
assertEquals(Path.of("/bar/bar.log"), ret.process.getLogFile());
System.out.println(ret);
}
}