Skip to content

Commit

Permalink
add testcase to help reproduce globalbioticinteractions/globalbiotici…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrit Poelen committed Sep 29, 2023
1 parent ce51e3a commit 86f03e7
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class CmdUpdateIT {

@Rule
private TemporaryFolder tmpDir = new TemporaryFolder();
public TemporaryFolder tmpDir = new TemporaryFolder();


@Test
Expand Down Expand Up @@ -51,6 +51,34 @@ public void runUpdate() throws IOException {
assertThat("number of cached files should not have changed after update", numberOfCacheFiles, is(getNumberOfCacheFiles()));
}

@Test
public void updateKnowledgePixels() throws IOException {

CmdUpdate cmd = new CmdUpdate();
File file1 = tmpDir.newFolder();
String absolutePath = file1.getAbsolutePath();
cmd.setCacheDir(absolutePath);
cmd.setNamespaces(Collections.singletonList("globalbioticinteractions/knowledgepixels"));

cmd.run();

File file = new File(file1,"globalbioticinteractions/knowledgepixels/access.tsv");
assertThat(file.exists(), is(true));
String[] jarUrls = FileUtils.readFileToString(file, StandardCharsets.UTF_8).split("jar:file:");
assertTrue(jarUrls.length > 1);
String localJarUrl = jarUrls[1].split("\t")[0];
assertNotNull(new URL("jar:file:" + localJarUrl).openStream());

int numberOfLogEntries = getNumberOfLogEntries();
assertThat(getNumberOfLogEntries() > 3, is(true));
int numberOfCacheFiles = getNumberOfCacheFiles();

// rerun
cmd.run();
assertThat("should update regardless or preexisting entries in cache", getNumberOfLogEntries() + 3 > numberOfLogEntries, is(true));
assertThat("number of cached files should not have changed after update", numberOfCacheFiles, is(getNumberOfCacheFiles()));
}

private int getNumberOfCacheFiles() {
return FileUtils.listFiles(new File(getDatasetCacheDir()), null, false).size();
}
Expand Down

0 comments on commit 86f03e7

Please sign in to comment.