Fix tests
This commit is contained in:
parent
92a00456c3
commit
c3a8df46d1
3 changed files with 21 additions and 3 deletions
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17_PREVIEW" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.wbrawner.plausible.android
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
|
@ -22,7 +23,7 @@ internal class NetworkFirstPlausibleClientTest {
|
|||
eventDir.delete()
|
||||
eventDir.mkdir()
|
||||
config = ThreadSafePlausibleConfig(eventDir, SCREEN_WIDTH)
|
||||
TODO("Set up a mock web server and validate the requests received are correct")
|
||||
// TODO("Set up a mock web server and validate the requests received are correct")
|
||||
}
|
||||
|
||||
@Ignore("Not yet implemented")
|
||||
|
@ -38,6 +39,24 @@ internal class NetworkFirstPlausibleClientTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `invalid persisted events are deleted`() {
|
||||
val invalidEvent = File(eventDir, "invalid-event.json")
|
||||
invalidEvent.createNewFile()
|
||||
invalidEvent.writeText("invalid jsopn")
|
||||
networkFirstClientTest {
|
||||
client.event(
|
||||
domain = "test.example.com",
|
||||
name = "eventUrl",
|
||||
url = "referrer",
|
||||
referrer = "referrer",
|
||||
screenWidth = SCREEN_WIDTH,
|
||||
props = mapOf("prop1" to "propVal")
|
||||
)
|
||||
}
|
||||
assertFalse(invalidEvent.exists())
|
||||
}
|
||||
|
||||
private fun networkFirstClientTest(test: suspend () -> Unit) = runBlocking {
|
||||
client = NetworkFirstPlausibleClient(config, coroutineContext)
|
||||
test()
|
||||
|
|
|
@ -52,6 +52,6 @@ internal class PlausibleTest {
|
|||
assertEquals("app://localhost/eventUrl", event.url)
|
||||
assertEquals(SCREEN_WIDTH, event.screenWidth)
|
||||
assertEquals("referrer", event.referrer)
|
||||
assertEquals("{\"prop1\":\"propVal\"}", event.props)
|
||||
assertEquals(mapOf("prop1" to "propVal"), event.props)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue