Skip to content

Commit f3f71aa

Browse files
committed
Simplify empty API key assertions
1 parent 77a5fe0 commit f3f71aa

2 files changed

Lines changed: 2 additions & 17 deletions

File tree

posthog-server/src/test/java/com/posthog/server/PostHogTest.kt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -454,28 +454,14 @@ internal class PostHogTest {
454454
}
455455

456456
@Test
457-
fun `empty api key disables SDK even with personal api key`() {
458-
val mockServer = MockWebServer()
459-
mockServer.start()
460-
461-
val url = mockServer.url("/").toString()
457+
fun `empty api key disables SDK`() {
462458
val postHog = PostHog()
463-
postHog.setup(
464-
PostHogConfig.builder(" \n\t ")
465-
.host(url)
466-
.personalApiKey("phx_test_personal_api_key")
467-
.flushAt(1)
468-
.build(),
469-
)
470459

471-
val flags = postHog.evaluateFlags("user123")
460+
postHog.setup(PostHogConfig.builder(" \n\t ").build())
472461

473462
assertTrue(postHog.isOptOut())
474-
assertFalse(flags.isEnabled("test-flag"))
475-
assertNull(mockServer.takeRequest(2, TimeUnit.SECONDS))
476463

477464
postHog.close()
478-
mockServer.shutdown()
479465
}
480466

481467
@Test

posthog/src/test/java/com/posthog/PostHogStatelessTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ internal class PostHogStatelessTest {
244244
sut.setup(config)
245245

246246
assertFalse(sut.isEnabledPublic())
247-
assertTrue(sut.isOptOut())
248247
assertTrue(mockLogger.messages.any { it.contains("PostHog SDK is disabled because the API key is required") })
249248
}
250249

0 commit comments

Comments
 (0)