-
Notifications
You must be signed in to change notification settings - Fork 14
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
425639c
commit f1ed6ad
Showing
11 changed files
with
221 additions
and
12 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
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
85 changes: 85 additions & 0 deletions
85
...Test/kotlin/io/embrace/android/embracesdk/testcases/features/FileAttachmentFeatureTest.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,85 @@ | ||
package io.embrace.android.embracesdk.testcases.features | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import io.embrace.android.embracesdk.Severity | ||
import io.embrace.android.embracesdk.testframework.IntegrationTestRule | ||
import io.embrace.android.embracesdk.testframework.assertions.assertOtelLogReceived | ||
import io.embrace.android.embracesdk.testframework.assertions.getLastLog | ||
import io.embrace.android.embracesdk.testframework.assertions.getOtelSeverity | ||
import java.util.UUID | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
internal class FileAttachmentFeatureTest { | ||
|
||
private val attachmentId = UUID.randomUUID() | ||
|
||
@Rule | ||
@JvmField | ||
val testRule: IntegrationTestRule = IntegrationTestRule() | ||
|
||
@Test | ||
fun `log message with user hosted file attachment`() { | ||
val size = 509L | ||
val url = "https://example.com/my-file.txt" | ||
val id = attachmentId.toString() | ||
testRule.runTest( | ||
testCaseAction = { | ||
recordSession { | ||
embrace.logMessage( | ||
message = "test message", | ||
severity = Severity.INFO, | ||
properties = mapOf("key" to "value"), | ||
attachmentId = id, | ||
attachmentUrl = url, | ||
attachmentSize = size, | ||
) | ||
} | ||
}, | ||
assertAction = { | ||
val log = getSingleLogEnvelope().getLastLog() | ||
assertOtelLogReceived( | ||
logReceived = log, | ||
expectedMessage = "test message", | ||
expectedSeverityNumber = getOtelSeverity(Severity.INFO).severityNumber, | ||
expectedSeverityText = Severity.INFO.name, | ||
expectedState = "foreground", | ||
expectedProperties = mapOf( | ||
"key" to "value", | ||
), | ||
) | ||
} | ||
) | ||
} | ||
|
||
@Test | ||
fun `log message with embrace hosted file attachment`() { | ||
testRule.runTest( | ||
testCaseAction = { | ||
recordSession { | ||
embrace.logMessage( | ||
message = "test message", | ||
severity = Severity.INFO, | ||
properties = mapOf("key" to "value"), | ||
attachment = "Hello, world!".toByteArray() | ||
) | ||
} | ||
}, | ||
assertAction = { | ||
val log = getSingleLogEnvelope().getLastLog() | ||
assertOtelLogReceived( | ||
logReceived = log, | ||
expectedMessage = "test message", | ||
expectedSeverityNumber = getOtelSeverity(Severity.INFO).severityNumber, | ||
expectedSeverityText = Severity.INFO.name, | ||
expectedState = "foreground", | ||
expectedProperties = mapOf( | ||
"key" to "value", | ||
), | ||
) | ||
} | ||
) | ||
} | ||
} |
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
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