-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy blacklisted files before they are removed
- Loading branch information
1 parent
f82ba8b
commit 324523f
Showing
2 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package hath.base; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
|
||
public class CacheHandlerTest { | ||
private HentaiAtHomeClient client; | ||
private CacheHandler cut; | ||
|
||
private Path sourceFile; | ||
private HVFile mockHVFile; | ||
private Settings settings; | ||
|
||
@BeforeEach | ||
public void createCacheHandler() throws Exception { | ||
client = mock(HentaiAtHomeClient.class); | ||
mockHVFile = mock(HVFile.class); | ||
settings = new Settings(); | ||
|
||
settings.updateSetting("skip_free_space_check", "true"); | ||
settings.updateSetting("temp_dir", Files.createTempDirectory("CacheHandlerTestTempDir").toString()); | ||
settings.initializeDirectories(); | ||
|
||
cut = new CacheHandler(client); | ||
sourceFile = Files.createTempFile("hath-client-CacheHandlerTest", null); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
cut.terminateCache(); | ||
} | ||
|
||
@Test | ||
public void testCopyFileFromCacheDir() throws Exception { | ||
when(mockHVFile.getLocalFileRef()).thenReturn(sourceFile.toFile()); | ||
cut.copyFileFromCacheDir(mockHVFile); | ||
|
||
assertThat(new File("data/blacklist/" + sourceFile.getFileName().toString()).exists(), is(true)); | ||
} | ||
} |