Skip to content

Commit

Permalink
Add tests where debug is not a map
Browse files Browse the repository at this point in the history
  • Loading branch information
prudrabhat committed Jun 18, 2024
1 parent bf2ec12 commit d135c3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private const val KEY_DEBUG_EVENT_TYPE = "eventType"
private const val KEY_DEBUG_EVENT_SOURCE = "eventSource"

/**
* Returns the debug event type (identified by data.debug.eventType) from the event data if present, otherwise null.
* Returns the debug event type (identified by debug.eventType) from the event data if present, otherwise null.
* @return the debug event type if present, otherwise null
*/
fun Event.getDebugEventType(): String? {
Expand All @@ -34,7 +34,7 @@ fun Event.getDebugEventType(): String? {
}

/**
* Returns the debug event source (identified by data.debug.eventSource) from the event data if present, otherwise null.
* Returns the debug event source (identified by debug.eventSource) from the event data if present, otherwise null.
* @return the debug event source if present, otherwise null
*/
fun Event.getDebugEventSource(): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ class EventUtilsTest {
assertNull(event.getDebugEventType())
}

@Test
fun `Test getDebugEventType returns null when debug is not a map`() {
val event = Event.Builder(TEST_EVENT_NAME, TEST_EVENT_TYPE, TEST_EVENT_SOURCE)
.setEventData(mapOf("debug" to "value")).build()

assertNull(event.getDebugEventType())
}

@Test
fun `Test getDebugEventType returns null on invalid debug key`() {
val event = Event.Builder(TEST_EVENT_NAME, TEST_EVENT_TYPE, TEST_EVENT_SOURCE)
Expand Down Expand Up @@ -120,6 +128,14 @@ class EventUtilsTest {
assertNull(event.getDebugEventSource())
}

@Test
fun `Test getDebugEventSource returns null when debug is not a map`() {
val event = Event.Builder(TEST_EVENT_NAME, TEST_EVENT_TYPE, TEST_EVENT_SOURCE)
.setEventData(mapOf("debug" to "value")).build()

assertNull(event.getDebugEventSource())
}

@Test
fun `Test getDebugEventSource returns null on no debug data`() {
val event = Event.Builder(TEST_EVENT_NAME, TEST_EVENT_TYPE, TEST_EVENT_SOURCE)
Expand Down

0 comments on commit d135c3d

Please sign in to comment.