-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f7a643
commit 56ba7fc
Showing
40 changed files
with
746 additions
and
53 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
16 changes: 16 additions & 0 deletions
16
Sentry/src/test/java/io/sentry/NoOpTransactionProfilerTest.kt
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,16 @@ | ||
package io.sentry | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertNull | ||
|
||
class NoOpTransactionProfilerTest { | ||
private var profiler = NoOpTransactionProfiler.getInstance() | ||
|
||
@Test | ||
fun `onTransactionStart does not throw`() = | ||
profiler.onTransactionStart(NoOpTransaction.getInstance()) | ||
|
||
@Test | ||
fun `onTransactionFinish returns null`() = | ||
assertNull(profiler.onTransactionFinish(NoOpTransaction.getInstance())) | ||
} |
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,77 @@ | ||
package io.sentry.util | ||
|
||
import java.io.File | ||
import java.nio.file.Files | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertNull | ||
import kotlin.test.assertTrue | ||
|
||
class FileUtilsTest { | ||
|
||
@Test | ||
fun `deleteRecursively returns true on null file`() { | ||
assertTrue(FileUtils.deleteRecursively(null)) | ||
} | ||
|
||
@Test | ||
fun `deleteRecursively returns true on non-existing file`() { | ||
assertTrue(FileUtils.deleteRecursively(File(""))) | ||
} | ||
|
||
@Test | ||
fun `deleteRecursively deletes a simple file`() { | ||
val f = Files.createTempFile("here", "test").toFile() | ||
assertTrue(f.exists()) | ||
assertTrue(FileUtils.deleteRecursively(f)) | ||
assertFalse(f.exists()) | ||
} | ||
|
||
@Test | ||
fun `deleteRecursively deletes a folder`() { | ||
// Setup vars | ||
val rootDir = Files.createTempDirectory("here").toFile() | ||
val rootChild = File(rootDir, "test") | ||
val innerDir = File(rootDir, "dir2") | ||
val innerChild = File(innerDir, "test") | ||
|
||
// Create directories and files | ||
rootChild.createNewFile() | ||
innerDir.mkdir() | ||
innerChild.createNewFile() | ||
|
||
// Assert dirs and files exist | ||
assertTrue(rootDir.exists() && rootDir.isDirectory) | ||
assertTrue(rootChild.exists()) | ||
assertTrue(innerDir.exists() && innerDir.isDirectory) | ||
assertTrue(innerChild.exists()) | ||
|
||
// Assert deletion returns true | ||
assertTrue(FileUtils.deleteRecursively(rootDir)) | ||
|
||
// Assert dirs and files no longer exist | ||
assertFalse(rootChild.exists()) | ||
assertFalse(rootDir.exists()) | ||
assertFalse(innerChild.exists()) | ||
assertFalse(innerDir.exists()) | ||
} | ||
|
||
@Test | ||
fun `readText returns null on null, non existing or unreadable file`() { | ||
val f = File("here", "test") | ||
val unreadableFile = Files.createTempFile("here", "test").toFile() | ||
unreadableFile.setReadable(false) | ||
assertNull(FileUtils.readText(null)) | ||
assertNull(FileUtils.readText(f)) | ||
assertNull(FileUtils.readText(unreadableFile)) | ||
} | ||
|
||
@Test | ||
fun `readText returns the content of a file`() { | ||
val f = Files.createTempFile("here", "test").toFile() | ||
val text = "Lorem ipsum dolor sit amet\nLorem ipsum dolor sit amet" | ||
f.writeText(text) | ||
assertEquals(text, FileUtils.readText(f)) | ||
} | ||
} |
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
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
Oops, something went wrong.