Skip to content

Commit

Permalink
added unit tests for #58
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed May 22, 2019
1 parent 1b8bf36 commit 5916093
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,29 @@ public void writeAfterEof() throws IOException {
Assertions.assertEquals(210l, inTest.size());
}

@Test
@DisplayName("write header if it isn't already written")
public void testWriteHeaderIfNeeded() throws IOException {
when(options.writable()).thenReturn(true);

inTest.force(true);
inTest.force(true);
inTest.force(true);

Mockito.verify(ciphertextFileChannel, Mockito.times(1)).write(Mockito.any(), Mockito.eq(0l));
}

@Test
@DisplayName("don't write header if it is already written")
public void testDontRewriteHeader() throws IOException {
when(options.writable()).thenReturn(true);
inTest = new CleartextFileChannel(ciphertextFileChannel, header, false, readWriteLock, cryptor, chunkCache, options, fileSize, lastModified, attributeViewSupplier, exceptionsDuringWrite, closeListener, stats);

inTest.force(true);

Mockito.verify(ciphertextFileChannel, Mockito.never()).write(Mockito.any(), Mockito.eq(0l));
}

}

@Nested
Expand Down

0 comments on commit 5916093

Please sign in to comment.