Skip to content

Commit

Permalink
added delete file after each test
Browse files Browse the repository at this point in the history
Signed-off-by: Basler182 <[email protected]>
  • Loading branch information
Basler182 committed Jun 23, 2024
1 parent 6ee145d commit 58b191d
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import edu.stanford.spezi.core.testing.runTestUnconfined
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -17,11 +18,17 @@ class EncryptedFileKeyValueStorageTest {
context = context,
ioDispatcher = UnconfinedTestDispatcher(),
)
private val fileName = "testFile"

@After
fun tearDown() = runTestUnconfined {
// Delete the file after each test to clean up
fileStorage.deleteFile(fileName)
}

@Test
fun `it should save and read file correctly`() = runTestUnconfined {
// Given
val fileName = "testFile"
val data = "Hello, World!".toByteArray()

// When
Expand All @@ -47,7 +54,6 @@ class EncryptedFileKeyValueStorageTest {
@Test
fun `it should overwrite existing file when saving with same filename`() = runTestUnconfined {
// Given
val fileName = "testFile"
val initialData = "Hello, World!".toByteArray()
val newData = "New data".toByteArray()

Expand All @@ -63,7 +69,6 @@ class EncryptedFileKeyValueStorageTest {
@Test
fun `it should delete file correctly`() = runTestUnconfined {
// Given
val fileName = "testFile"
val data = "Hello, World!".toByteArray()
fileStorage.saveFile(fileName, data)

Expand Down

0 comments on commit 58b191d

Please sign in to comment.