Fix ensureDbDirectoryExists
This commit is contained in:
parent
af119db1d7
commit
fcfdcd1025
2 changed files with 21 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import android.content.SharedPreferences
|
|||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assume
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
|
@ -85,6 +86,25 @@ class ContentSettingsManagerTest {
|
|||
assertFalse(settings.exists())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Ensuring db directory existence must work`() {
|
||||
val dir = Files.createTempDirectory("newpipe_").toFile()
|
||||
Assume.assumeTrue(dir.delete())
|
||||
`when`(fileLocator.dbDir).thenReturn(dir)
|
||||
|
||||
ContentSettingsManager(fileLocator).ensureDbDirectoryExists()
|
||||
assertTrue(dir.exists())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Ensuring db directory existence must work when the directory already exists`() {
|
||||
val dir = Files.createTempDirectory("newpipe_").toFile()
|
||||
`when`(fileLocator.dbDir).thenReturn(dir)
|
||||
|
||||
ContentSettingsManager(fileLocator).ensureDbDirectoryExists()
|
||||
assertTrue(dir.exists())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `The database must be extracted from the zip file`() {
|
||||
val db = File.createTempFile("newpipe_", "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue